public STUNClient(NetworkProtocol p) { protocol = p; protocol.AttachResponseListener(ChannelType.STUN, OnResponse); protocol.AttachErrorListener(NetworkErrorType.ErrorNoResponseSTUN, OnError); transactionID = GenerateTransactionID(); }
public NetworkPeer(NetworkProtocol p) { protocol = p; for (int i = 0; i < (int)ChannelType.LAST; i++) { messageSequence.Add(0); } }
public void AttachToProtocol(NetworkProtocol p) { local = new NetworkPeer(p); protocol = p; protocol.OnReadHeader += OnReadHeader; protocol.OnWriteHeader += OnWriteHeader; protocol.AttachRequestListener(ChannelType.Server, OnRequestConnectToServer); protocol.AttachResponseListener(ChannelType.Server, OnResponseConnectToServer); protocol.AttachErrorListener(NetworkErrorType.ErrorConnectToServer, OnErrorConnectToServer); //local.id = 0;// ServerGeneratePeerId(protocol.socket.sendSocket.LocalEndPoint); }