55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using System;
|
|
using ln.types.btree;
|
|
using ln.types.net;
|
|
using skyspot.session;
|
|
using skyspot.ip;
|
|
namespace skyspot.hotspot
|
|
{
|
|
public class HotspotNetworkRuntime
|
|
{
|
|
public HotspotNetwork HotspotNetwork { get; private set; }
|
|
|
|
MappingBTree<MAC, ClientSession> currentSessions = new MappingBTree<MAC, ClientSession>((ClientSession clientSession)=>clientSession.ClientMAC);
|
|
IPPool<ClientSession> pool = new IPPool<ClientSession>();
|
|
|
|
|
|
private HotspotNetworkRuntime()
|
|
{
|
|
}
|
|
public HotspotNetworkRuntime(HotspotNetwork hotspotNetwork)
|
|
{
|
|
HotspotNetwork = hotspotNetwork;
|
|
}
|
|
|
|
public ClientSession GetSession(MAC clientMac)
|
|
{
|
|
if (!currentSessions.ContainsKey(clientMac))
|
|
{
|
|
ClientSession newSession = new ClientSession(HotspotNetwork, clientMac);
|
|
FixupSession(newSession);
|
|
currentSessions.Add(newSession);
|
|
return newSession;
|
|
}
|
|
else
|
|
{
|
|
ClientSession clientSession = currentSessions[clientMac];
|
|
FixupSession(clientSession);
|
|
return clientSession; ;
|
|
}
|
|
}
|
|
public void RemoveSession(MAC clientMac)
|
|
{
|
|
currentSessions.RemoveKey(clientMac);
|
|
}
|
|
|
|
private void FixupSession(ClientSession clientSession)
|
|
{
|
|
if (clientSession.ClientIP == null)
|
|
{
|
|
// Todo: Implement IP allocation from pool
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|