private static void onConnect(Connection connection) { Console.WriteLine(connection.ConnectionInfo.RemoteEndPoint); //TODO generate rendom keys sbyte[] encKey = { 00, 00, 00, 00 }; CCM.AddCC(connection, encKey); var packet = new AuthPackets.S2CHelloPacket(encKey); packet.Send(connection); }
public static void UpdateOrAddClient(Connection connection, out Client client) { var guid = connection.ConnectionInfo.NetworkIdentifier; Console.WriteLine(Resources.ClientManager_UpdateOrAddClient_Load + guid); if (_connectedClients.ContainsKey(guid)) { client = _connectedClients[guid]; switch (client.getAtZone()) { case atZone.afterLogin: client.ServerConnection = connection; client.setAtZone(atZone.atCharSelect); return; case atZone.atCharSelect: client.ChannelConnection = connection; return; case atZone.atVillage: client.setAtZone(atZone.connectedToServer); client.AuthConnection = connection; var packet1 = new AuthPackets.S2CAnsConnect(true); packet1.Send(connection); return; } _connectedClients[guid].AuthConnection = connection; _connectedClients[guid].setAtZone(atZone.connectedToServer); Console.WriteLine(Resources.ClientManager_UpdateOrAddClient_UpdateSuccess, guid); return; } client = new Client(connection, guid); _connectedClients.Add(guid, client); var packet = new AuthPackets.S2CHelloPacket(client.EncryptionKey); packet.Send(connection); Console.WriteLine(Resources.ClientManager_UpdateOrAddClient_ClientAddSuccess, guid); }