예제 #1
0
파일: RUDP.cs 프로젝트: isarzhan/RUDPSharp
 protected void SendTo(EndPoint endPoint, PacketType packetType, Channel channel, ReadOnlySpan <byte> payload)
 {
     if (!remotes.TryGetValue(endPoint, out RUDPRemoteClient <T> client))
     {
         client = new RUDPRemoteClient <T> (this, endPoint);
         remotes.TryAdd(endPoint, client);
     }
     remotes[endPoint].QueueOutgoing(endPoint, packetType, channel, payload);
 }
예제 #2
0
파일: RUDP.cs 프로젝트: isarzhan/RUDPSharp
        void ReadSocket()
        {
            RUDPRemoteClient <T> client;

            try {
                while (!tokenSource.IsCancellationRequested)
                {
                    foreach (var incoming in socket.RecievedPackets.GetConsumingEnumerable(tokenSource.Token))
                    {
                        if (!remotes.TryGetValue(incoming.remote, out client))
                        {
                            client = new RUDPRemoteClient <T> (this, incoming.remote);
                            remotes[incoming.remote] = client;
                        }
                        client.QueueIncoming(incoming.remote, incoming.data);
                    }
                }
            } catch (Exception ex) {
            }
        }