/// <summary> /// A cityserver requested a decryptionkey for a client! /// </summary> public static void HandleKeyFetch(ref LoginListener Listener, PacketStream P, CityServerClient Client) { string AccountName = P.ReadString(); byte[] EncKey = new byte[1]; foreach (LoginClient Cl in Listener.Clients) { if (Cl.Username == AccountName) { EncKey = Cl.EncKey; if (Cl.CurrentlyActiveSim.CreatedThisSession) { //TODO: Update the DB to reflect the city that // this sim resides in. Database.UpdateCityForCharacter(Cl.CurrentlyActiveSim.Name, Client.ServerInfo.Name); } } } PacketStream OutPacket = new PacketStream(0x01, 0x00); OutPacket.WriteByte((byte)0x01); OutPacket.WriteByte((byte)(EncKey.Length + 2)); OutPacket.WriteByte((byte)EncKey.Length); OutPacket.Write(EncKey, 0, EncKey.Length); Client.Send(OutPacket.ToArray()); //For now, assume client has already disconnected and doesn't need to be disconnected manually. Listener.TransferringClients.Remove(Client); }
public static void HandlePulse(PacketStream P, ref CityServerClient Client) { if (Client.ServerInfo != null) { Client.ServerInfo.Online = true; } Client.LastPulseReceived = DateTime.Now; }
/// <summary> /// A cityserver logged in! /// </summary> public static void HandleCityServerLogin(PacketStream P, ref CityServerClient Client) { byte PacketLength = (byte)P.ReadByte(); string Name = P.ReadString(); string Description = P.ReadString(); ulong Thumbnail = P.ReadUInt64(); string IP = P.ReadString(); int Port = P.ReadInt32(); CityServerInfo Info = new CityServerInfo(Name, Description, Thumbnail, IP, Port); Client.ServerInfo = Info; }
/// <summary> /// A cityserver logged in! /// </summary> public static void HandleCityServerLogin(PacketStream P, ref CityServerClient Client) { byte PacketLength = (byte)P.ReadByte(); Logger.LogDebug("CityServer logged in!"); string Name = P.ReadString(); string Description = P.ReadString(); ulong Thumbnail = P.ReadUInt64(); Guid GUID = new Guid(); string UUID = GUID.ToString(); ulong Map = P.ReadUInt64(); string IP = P.ReadString(); int Port = P.ReadInt32(); CityInfo Info = new CityInfo(Name, Description, Thumbnail, UUID, Map, IP, Port); Client.ServerInfo = Info; }
public static void HandlePulse(NetworkClient Client, ProcessedPacket P) { try { CityServerClient CityClient = (CityServerClient)Client; if (CityClient.ServerInfo != null) { CityClient.ServerInfo.Online = true; } CityClient.LastPulseReceived = DateTime.Now; NetworkFacade.CServerListener.UpdateClient(CityClient); } catch (Exception E) { Logger.LogDebug("Exception in HandlePulse:\r\n" + E.ToString()); } }
/// <summary> /// A cityserver logged in! /// </summary> public static void HandleCityServerLogin(NetworkClient Client, ProcessedPacket P) { CityServerClient CityClient = (CityServerClient)Client; Logger.LogInfo("CityServer logged in!\r\n"); string Name = P.ReadString(); string Description = P.ReadString(); string IP = P.ReadString(); int Port = P.ReadInt32(); CityInfoStatus Status = (CityInfoStatus)P.ReadByte(); ulong Thumbnail = P.ReadUInt64(); string UUID = P.ReadString(); ulong Map = P.ReadUInt64(); CityInfo Info = new CityInfo(Name, Description, Thumbnail, UUID, Map, IP, Port); Info.Status = Status; CityClient.ServerInfo = Info; //Client instance changed, so update it... NetworkFacade.CServerListener.UpdateClient(CityClient); }
/// <summary> /// Called by CityServer instances /// when they've received some new data /// (a new packet). Should not be called /// from anywhere else. /// </summary> /// <param name="P"></param> public void OnReceivedData(PacketStream P, CityServerClient Client) { OnReceiveEvent(P, ref Client); }
/// <summary> /// Handles incoming packets from a CityServer. /// </summary> private void m_CServerListener_OnReceiveEvent(PacketStream P, ref CityServerClient Client) { byte ID = (byte)P.ReadByte(); switch (ID) { case 0x00: CityServerPacketHandlers.HandleCityServerLogin(P, ref Client); break; case 0x01: CityServerPacketHandlers.HandleKeyFetch(ref NetworkFacade.ClientListener, P, Client); break; case 0x02: CityServerPacketHandlers.HandlePulse(P, ref Client); break; } }
/// <summary> /// Handles incoming packets from a CityServer. /// </summary> void m_CServerListener_OnReceiveEvent(PacketStream P, CityServerClient Client) { byte ID = (byte)P.ReadByte(); switch (ID) { case 0x00: CityServerPacketHandlers.HandleCityServerLogin(P, ref Client); break; case 0x01: CityServerPacketHandlers.HandleKeyFetch(ref m_Listener, P, Client); break; } }
public static void HandlePulse(PacketStream P, ref CityServerClient Client) { if(Client.ServerInfo != null) Client.ServerInfo.Online = true; Client.LastPulseReceived = DateTime.Now; }