public static void HandlePacket(StarNetNode node, StarboundClient client, IStarboundPacket packet) { if (PacketHandlers.ContainsKey(packet.PacketId)) { PacketHandlers[packet.PacketId](node, client, packet); } }
internal void DropClient(StarboundClient client) { lock (ClientLock) { client.DropAsync(); Clients.Remove(client); Console.WriteLine("Dropped client {0}", client.UUID); } }
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); }