public PeerDisconnectedEventArgs(Peer peer, string reason) : base(peer) { DisconnectReason = reason; }
public PeerConnectedEventArgs(Peer peer) : base(peer) { }
public PeerEventArgs(Peer peer) { Peer = peer; }
public PacketEventArgs(Peer peer, IPacket packet, int rawPacketSize) { SourcePeer = peer; Packet = packet; RawPacketSize = rawPacketSize; }
private async void AcceptAsync() { while (true) { var client = await _uNetSock.AcceptTcpClientAsync(); var peer = new Peer(client, this, Settings); //Subscribe to peer events peer.OnPeerDisconnected += PeerDisconnect; peer.OnPacketReceived += (o, e) => { if(OnPacketReceived != null) { OnPacketReceived(o, e); } }; peer.InternalOnPacketReceived += InternalOnPacketReceived; peer.Processor.OnPacketSent += (o, e) => { if (OnPacketSent != null) { OnPacketSent(null, new PacketEventArgs(null, e.Packet, e.RawPacketSize)); } }; ConnectedPeers.Add(peer); if (_debug) Debug.Print("Peer connected from: " + peer.RemoteEndPoint); if (OnPeerConnected != null) OnPeerConnected(null, new PeerConnectedEventArgs(peer)); } }