Exemplo n.º 1
0
        private void MessageReceived(Paket paket, IpEndpoint ipEndpoint)
        {
            if (paket.Count < 2 || paket.Count > 1024)
            {
                _trace.Error("Received datagram with invalid count: {0}", paket.Count);
                return;
            }
            var protocolVersion = paket.Array[0] & 7;

            if (protocolVersion != Connection.ProtocolVersion)
            {
                _trace.Error("Discarding Message with different protocol version. Was: {0} Expected: {1}", protocolVersion, Connection.ProtocolVersion);
                return;
            }
            ServerPeer serverPeer;

            if (!_serverPeers.TryGetValue(ipEndpoint, out serverPeer))
            {
                serverPeer = new ServerPeer(ipEndpoint, _listenerBase.Listener.ForkSendTo(ipEndpoint), _trace);
                _serverPeers.Add(ipEndpoint, serverPeer);
                OnNewServerPeer(this, serverPeer);
            }
            serverPeer.MessageReceived(paket);
        }
Exemplo n.º 2
0
 private void OnNewConnection(ServerPeer arg1, Connection arg2)
 {
     NewConnection?.Invoke(arg1, arg2);
 }