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 currentSessions = new MappingBTree((ClientSession clientSession)=>clientSession.ClientMAC); IPPool pool = new IPPool(); 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 } } } }