public void AddSession(ClientConnection connection, Session.Channel type, uint id) { Session session = new Session(id, connection, type); switch (type) { case Session.Channel.ZONE: //New character since world server loaded if (!mIdToNameMap.ContainsKey(id)) { AddNameToMap(id, session.characterName); } //TODO: this is technically wrong!!! Should kick out player and wait till auto-removed. if (mZoneSessionList.ContainsKey(id)) { mZoneSessionList.Remove(id); } mZoneSessionList.Add(id, session); break; case Session.Channel.CHAT: if (!mChatSessionList.ContainsKey(id)) { mChatSessionList.Add(id, session); } break; } }
public Session GetSession(uint targetSession, Session.Channel type = Session.Channel.ZONE) { switch (type) { case Session.Channel.ZONE: if (mZoneSessionList.ContainsKey(targetSession)) { return(mZoneSessionList[targetSession]); } break; case Session.Channel.CHAT: if (mChatSessionList.ContainsKey(targetSession)) { return(mChatSessionList[targetSession]); } break; } return(null); }
public void RemoveSession(Session.Channel type, uint id) { switch (type) { case Session.Channel.ZONE: if (mZoneSessionList.ContainsKey(id)) { mZoneSessionList[id].clientConnection.Disconnect(); mConnectionList.Remove(mZoneSessionList[id].clientConnection); mZoneSessionList.Remove(id); } break; case Session.Channel.CHAT: if (mChatSessionList.ContainsKey(id)) { mChatSessionList[id].clientConnection.Disconnect(); mConnectionList.Remove(mChatSessionList[id].clientConnection); mChatSessionList.Remove(id); } break; } }