Beispiel #1
0
        private static void OnC2SAskConnect(ByteBuffer buffer, Connection connection)
        {
            var incPacket = new AuthPackets.C2SAskConnect(buffer, connection);
            var protocol  = incPacket.ProtocolVersion;
            var Address   = incPacket.serverAddress; //Could also be Client Address
            //TODO check if he should be able to connect
            var canConnect = true;
            var outPacket  = new AuthPackets.S2CAnsConnect(canConnect);

            outPacket.Send(connection);
        }
        internal static void OnC2SAskConnect(ByteBuffer buffer, Connection connection)
        {
            var incPacket = new AuthPackets.C2SAskConnect(buffer, connection);
            //Get Protocol Version
            var protocolBytes = incPacket.ProtocolVersion;
            var protocol      = protocolBytes[0] + "." + protocolBytes[1] + "." + protocolBytes[2];

            var address = incPacket.serverAddress; //Could also be Client Address
            //Check if Protocol Versions Match
            var canConnect = (protocol == ConfigurationManager.AppSettings["protocolVersion"]);
            var outPacket  = new AuthPackets.S2CAnsConnect(canConnect);

            outPacket.Send(connection);
        }
Beispiel #3
0
        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);
        }