internal void OnPeerDataReceived(Peer peer, byte[] data) { _worker.Queue(()=>DataReceived(peer, data)); }
internal void OnPeerDataSent(Peer peer, byte[] data) { _worker.Queue(()=>DataSent(peer, data)); }
internal void OnClosed(Peer peer) { _worker.Queue(() => Closed(peer)); }
internal void OnPeerConnected(Peer peer) { _worker.Queue(()=>Connected(peer)); }
public virtual void DataSent(Peer peer, byte[] data) { }
public virtual void DataReceived(Peer peer, byte[] data) { }
public virtual void Connected(Peer peer) { }
public virtual void Closed(Peer peer) { }
private void RegisterPeer(IConnection connection) { var peer = new Peer(connection); _peers.TryAdd(peer.Connection.Endpoint, peer); Events.RaiseAsync(PeerConnected, this, new PeerEventArgs(peer)); }