public STUNServer(IPEndPoint primaryEndPoint, STUNSendMessageDelegate primarySend, IPEndPoint secondaryEndPoint, STUNSendMessageDelegate secondarySend) { m_primaryEndPoint = primaryEndPoint; m_primarySend = primarySend; m_secondaryEndPoint = secondaryEndPoint; m_secondarySend = secondarySend; m_primaryDiffPortSocket = NetServices.CreateRandomUDPListener(m_primaryEndPoint.Address, out m_primaryDiffPortEndPoint); m_secondaryDiffPortSocket = NetServices.CreateRandomUDPListener(m_secondaryEndPoint.Address, out m_secondaryDiffPortEndPoint); logger.LogDebug("STUN Server additional sockets, primary=" + IPSocket.GetSocketString(m_primaryDiffPortEndPoint) + ", secondary=" + IPSocket.GetSocketString(m_secondaryDiffPortEndPoint) + "."); }
public STUNServer(IPEndPoint primaryEndPoint, STUNSendMessageDelegate primarySend, IPEndPoint secondaryEndPoint, STUNSendMessageDelegate secondarySend) { m_primaryEndPoint = primaryEndPoint; m_primarySend = primarySend; m_secondaryEndPoint = secondaryEndPoint; m_secondarySend = secondarySend; m_primaryDiffPortSocket = NetServices.CreateRandomUDPListener(m_primaryEndPoint.Address, out m_primaryDiffPortEndPoint); m_secondaryDiffPortSocket = NetServices.CreateRandomUDPListener(m_secondaryEndPoint.Address, out m_secondaryDiffPortEndPoint); logger.Debug("STUN Server additional sockets, primary=" + IPSocket.GetSocketString(m_primaryDiffPortEndPoint) + ", secondary=" + IPSocket.GetSocketString(m_secondaryDiffPortEndPoint) + "."); }
private void StartSTUNServer(IPEndPoint primaryEndPoint, IPEndPoint secondaryEndPoint, SIPTransport sipTransport) { STUNListener secondarySTUNListener = new STUNListener(secondaryEndPoint); // This end point is only for secondary STUN messages. STUNSendMessageDelegate primarySend = (dst, buffer) => { m_sipTransport.SendRaw(m_sipTransport.GetDefaultSIPEndPoint(SIPProtocolsEnum.udp), new SIPEndPoint(dst), buffer); }; m_stunServer = new STUNServer(primaryEndPoint, primarySend, secondaryEndPoint, secondarySTUNListener.Send); sipTransport.STUNRequestReceived += m_stunServer.STUNPrimaryReceived; sipTransport.STUNRequestReceived += LogPrimarySTUNRequestReceived; secondarySTUNListener.MessageReceived += m_stunServer.STUNSecondaryReceived; secondarySTUNListener.MessageReceived += LogSecondarySTUNRequestReceived; logger.Debug("STUN server successfully initialised."); }