Esempio n. 1
0
 public static void HandlePacket(StarNetNode node, StarboundClient client, IStarboundPacket packet)
 {
     if (PacketHandlers.ContainsKey(packet.PacketId))
     {
         PacketHandlers[packet.PacketId](node, client, packet);
     }
 }
Esempio n. 2
0
 internal void DropClient(StarboundClient client)
 {
     lock (ClientLock)
     {
         client.DropAsync();
         Clients.Remove(client);
         Console.WriteLine("Dropped client {0}", client.UUID);
     }
 }
Esempio n. 3
0
        private void AcceptClient(IAsyncResult result)
        {
            var socket = Listener.EndAcceptSocket(result);

            Listener.BeginAcceptSocket(AcceptClient, null);
            Console.WriteLine("New connection from {0}", socket.RemoteEndPoint);
            var client = new StarboundClient(socket);

            lock (ClientLock) Clients.Add(client);
            client.PacketQueue.Enqueue(new ProtocolVersionPacket(ProtocolVersion));
            client.FlushPackets();
            client.Socket.BeginReceive(client.PacketReader.NetworkBuffer, 0, client.PacketReader.NetworkBuffer.Length,
                                       SocketFlags.None, ClientDataReceived, client);
        }