/** * Creates and starts a new access point based on the specified socket. * If the specified access point has already been installed the method * has no effect. * * @param socket the socket that the access point should use. * @return an access point descriptor to allow further management of the * newly created access point. * @throws StunException if we fail to create or start the accesspoint. */ public NetAccessPointDescriptor InstallNetAccessPoint(MyUdpClient socket) { //no null check - let it through a null pointer exception StunAddress address = new StunAddress(socket.GetAddress().ToString(), socket.GetPort()); NetAccessPointDescriptor apDescriptor = new NetAccessPointDescriptor(address); if (netAccessPoints.ContainsKey(apDescriptor)) { return(apDescriptor); } NetAccessPoint ap = new NetAccessPoint(apDescriptor, messageQueue, this); //call the useExternalSocket method to avoid closing the socket when //removing the accesspoint. Bug Report - Dave Stuart - SipQuest ap.UseExternalSocket(socket); netAccessPoints[apDescriptor] = (ap); ap.Start(); return(apDescriptor); }
/** * The listening thread's run method. */ public virtual void Run() { while (this.isRunning) { try { byte[] message; IPEndPoint rep = null; message = sock.Receive(ref rep); RawMessage rawMessage = new RawMessage(message, message.Length, rep.Address, rep.Port, sock.GetAddress(), sock.GetPort(), GetDescriptor()); messageQueue.Add(rawMessage); } catch (Exception ex) { if (!isRunning) { return; } /** @todo do some better loggin will ya!!! */ // Console.WriteLine("A net access point has gone useless: {0} {1}", ex.Message, ex.StackTrace); Stop(); errorHandler.HandleFatalError( this, "Unknown error occurred while listening for messages!", ex); } } }
/** * Creates and starts a new access point based on the specified socket. * If the specified access point has already been installed the method * has no effect. * * @param socket the socket that the access point should use. * @return an access point descriptor to allow further management of the * newly created access point. * @throws StunException if we fail to create or start the accesspoint. */ public NetAccessPointDescriptor InstallNetAccessPoint(MyUdpClient socket) { //no null check - let it through a null pointer exception StunAddress address = new StunAddress(socket.GetAddress().ToString(), socket.GetPort()); NetAccessPointDescriptor apDescriptor = new NetAccessPointDescriptor(address); if(netAccessPoints.ContainsKey(apDescriptor)) return apDescriptor; NetAccessPoint ap = new NetAccessPoint(apDescriptor, messageQueue, this); //call the useExternalSocket method to avoid closing the socket when //removing the accesspoint. Bug Report - Dave Stuart - SipQuest ap.UseExternalSocket(socket); netAccessPoints[apDescriptor] = (ap); ap.Start(); return apDescriptor; }