private async Task OnClientPacket(GateConnection gate, int handle, Packet packet)
        {
            if (!gate.Clients.TryGetValue(handle, out ClientState client))
            {
                return;
            }

            await _packetProcessExecutor.Execute(client, packet);
        }
예제 #2
0
        private async void Listener_OnClientConnect(object sender, IConnection e)
        {
            var gate = new GateConnection(e);

            if (!_state.Gates.TryAdd(e.Handle, gate))
            {
                await e.Disconnect();
            }
        }
 private async Task OnClientConnectionChanged(GameState state, GateConnection gate, ClientConnectionChanged packet)
 {
     if (packet.Connected)
     {
         gate.Clients.TryAdd(packet.SocketHandle, new ClientState(gate, packet.SocketHandle));
     }
     else
     {
         if (gate.Clients.TryRemove(packet.SocketHandle, out ClientState client))
         {
             await client.Disconnect("Client disconnection");
         }
     }
 }