/// <summary> /// Cleans up any resources being used. /// </summary> public override void Dispose() { lock (SyncRoot) { if (m_pTimer100 != null) { m_pTimer100.Dispose(); m_pTimer100 = null; } if (m_pTimerG != null) { m_pTimerG.Dispose(); m_pTimerG = null; } if (m_pTimerH != null) { m_pTimerH.Dispose(); m_pTimerH = null; } if (m_pTimerI != null) { m_pTimerI.Dispose(); m_pTimerI = null; } if (m_pTimerJ != null) { m_pTimerJ.Dispose(); m_pTimerJ = null; } } }
/// <summary> /// Cleans up any resources being used. /// </summary> public override void Dispose() { lock (this.SyncRoot){ if (this.IsDisposed) { return; } // Log if (this.Stack.Logger != null) { this.Stack.Logger.AddText(this.ID, "Transaction [branch='" + this.ID + "';method='" + this.Method + "';IsServer=false] disposed."); } // Kill timers. if (m_pTimerA != null) { m_pTimerA.Dispose(); m_pTimerA = null; } if (m_pTimerB != null) { m_pTimerB.Dispose(); m_pTimerB = null; } if (m_pTimerD != null) { m_pTimerD.Dispose(); m_pTimerD = null; } if (m_pTimerE != null) { m_pTimerE.Dispose(); m_pTimerE = null; } if (m_pTimerF != null) { m_pTimerF.Dispose(); m_pTimerF = null; } if (m_pTimerK != null) { m_pTimerK.Dispose(); m_pTimerK = null; } this.ResponseReceived = null; base.Dispose(); } }
/// <summary> /// Cleans up any resource being used. /// </summary> public void Dispose() { lock (m_pLock){ if (this.State == SIP_CallState.Disposed) { return; } SetState(SIP_CallState.Disposed); // TODO: Clean up m_pStack = null; m_pLocalSDP = null; if (m_pDialog != null) { m_pDialog.Dispose(); m_pDialog = null; } m_pFlow = null; if (m_pKeepAliveTimer != null) { m_pKeepAliveTimer.Dispose(); m_pKeepAliveTimer = null; } this.StateChanged = null; } }
/// <summary> /// Cleans up any resource being used. /// </summary> public void Dispose() { lock (m_pLock) { if (this.State == DNS_ClientTransactionState.Disposed) { return; } SetState(DNS_ClientTransactionState.Disposed); if (m_pTimeoutTimer != null) { m_pTimeoutTimer.Dispose(); m_pTimeoutTimer = null; } m_pOwner = null; m_pResponse = null; this.StateChanged = null; this.Timeout = null; } }
/// <summary> /// Cleans up any resources being used. /// </summary> internal void Dispose() { m_pCache = null; m_pTimerTimeout.Dispose(); m_pTimerTimeout = null; }
/// <summary> /// Stops TCP server, all active connections will be terminated. /// </summary> public void Stop() { if (!m_IsRunning) { return; } foreach (TCP_ServerSession tss in Sessions.ToArray())//断开所有连接 { tss.Disconnect(); //tss.Dispose(); } m_IsRunning = false; // Dispose all old binds. foreach (ListeningPoint listeningPoint in m_pListeningPoints.ToArray()) { try { listeningPoint.Socket.Close(); } catch (Exception x) { OnError(x); } } m_pListeningPoints.Clear(); m_pTimer_IdleTimeout.Dispose(); m_pTimer_IdleTimeout = null; OnStopped(); }
private void wfrm_RTP_Debug_FormClosing(object sender, FormClosingEventArgs e) { m_IsDisposed = true; m_pSession.Error -= new EventHandler <LumiSoft.Net.ExceptionEventArgs>(m_pSession_Error); m_pSession.SessionCreated -= new EventHandler <LumiSoft.Net.EventArgs <RTP_Session> >(m_pSession_SessionCreated); m_pSession.NewParticipant -= new EventHandler <RTP_ParticipantEventArgs>(m_pSession_NewParticipant); m_pSession.LocalParticipant.SourceAdded -= new EventHandler <RTP_SourceEventArgs>(Participant_SourceAdded); m_pSession.LocalParticipant.SourceRemoved -= new EventHandler <RTP_SourceEventArgs>(Participant_SourceRemoved); m_pTimer.Dispose(); }
/// <summary> /// Cleans up nay resource being used. /// </summary> public void Dispose() { if (m_pNonces == null) { m_pNonces.Clear(); m_pNonces = null; } if (m_pTimer != null) { m_pTimer.Dispose(); m_pTimer = null; } }
/// <summary> /// Cleans up any resource being used. /// </summary> public void Dispose() { m_pTimeoutTimer.Dispose(); m_pTimeoutTimer = null; m_pOwner.m_pTransactions.Remove(this.ID); m_pOwner = null; m_pQuery = null; m_pResponse = null; this.Timeout = null; this.Completed = null; }
/// <summary> /// Cleans up any resources being used. /// </summary> public void Dispose() { if (m_IsDisposed) { return; } m_IsDisposed = true; m_pStack = null; m_pTimer.Dispose(); m_pTimer = null; SetState(SIP_UA_RegistrationState.Disposed); OnDisposed(); this.Registered = null; this.Unregistered = null; this.Error = null; this.Disposed = null; }
/// <summary> /// Cleans up any resources being used. /// </summary> public void Dispose() { lock (m_pLock){ if (m_IsDisposed) { return; } m_IsDisposed = true; m_pDialog.m_pUasInvite2xxRetransmits.Remove(this); if (m_pTimer != null) { m_pTimer.Dispose(); m_pTimer = null; } m_pDialog = null; m_pResponse = null; } }
/// <summary> /// Stops TCP server, all active connections will be terminated. /// </summary> public void Stop() { if (!m_IsRunning) { return; } m_IsRunning = false; // Dispose all old TCP acceptors. foreach (TCP_Acceptor acceptor in m_pConnectionAcceptors.ToArray()) { try { acceptor.Dispose(); } catch (Exception x) { OnError(x); } } m_pConnectionAcceptors.Clear(); // Dispose all old binds. foreach (ListeningPoint listeningPoint in m_pListeningPoints.ToArray()) { try { listeningPoint.Socket.Close(); } catch (Exception x) { OnError(x); } } m_pListeningPoints.Clear(); m_pTimer_IdleTimeout.Dispose(); m_pTimer_IdleTimeout = null; OnStopped(); }
/// <summary> /// Cleans up any resources being used. /// </summary> internal void Dispose() { if (m_IsDisposed) { return; } m_IsDisposed = true; this.CanRegister = null; this.AorRegistered = null; this.AorUnregistered = null; this.AorUpdated = null; m_pProxy = null; m_pStack = null; m_pRegistrations = null; if (m_pTimer != null) { m_pTimer.Dispose(); m_pTimer = null; } }
/// <summary> /// Stops SMTP relay server. /// </summary> /// <exception cref="ObjectDisposedException">Is raised when this object is disposed and this method is accessed.</exception> public virtual void Stop() { if (m_IsDisposed) { throw new ObjectDisposedException(this.GetType().Name); } if (!m_IsRunning) { return; } m_IsRunning = false; // TODO: We need to send notify to all not processed messages, then they can be Disposed as needed. // Clean up. m_pLocalEndPointIPv4 = null; m_pLocalEndPointIPv6 = null; //m_pSessions.Dispose(); m_pSessions = null; m_pConnectionsPerIP = null; m_pTimerTimeout.Dispose(); m_pTimerTimeout = null; }
/// <summary> /// Cleans up any resources being used. /// </summary> public void Dispose() { lock (m_pLock){ if (m_IsDisposed) { return; } OnDisposing(); m_IsDisposed = true; if (m_pTcpSession != null) { m_pTcpSession.Dispose(); m_pTcpSession = null; } m_pMessage = null; if (m_pKeepAliveTimer != null) { m_pKeepAliveTimer.Dispose(); m_pKeepAliveTimer = null; } } }
public void Close() { _timer.Stop(); _timer.Dispose(); }
/// <summary> /// Starts data connection processing. /// </summary> /// <exception cref="ObjectDisposedException">Is raised when this is disposed and this method is accessed.</exception> public void Start() { if(m_IsDisposed){ throw new ObjectDisposedException(this.GetType().Name); } // Passive mode, start waiting client connection. if(m_pSession.PassiveMode){ WriteLine("150 Waiting data connection on port '" + ((IPEndPoint)m_pSession.m_pPassiveSocket.LocalEndPoint).Port + "'."); // Start connection wait timeout timer. TimerEx timer = new TimerEx(10000,false); timer.Elapsed += delegate(object sender,System.Timers.ElapsedEventArgs e){ WriteLine("550 Data connection wait timeout."); Dispose(); }; timer.Enabled = true; m_pSession.m_pPassiveSocket.BeginAccept( delegate(IAsyncResult ar){ try{ timer.Dispose(); m_pSocket = m_pSession.m_pPassiveSocket.EndAccept(ar); // Log m_pSession.LogAddText("Data connection opened."); StartDataTransfer(); } catch{ WriteLine("425 Opening data connection failed."); Dispose(); } }, null ); } // Active mode, connect to client data port. else{ WriteLine("150 Opening data connection to '" + m_pSession.m_pDataConEndPoint.ToString() + "'."); m_pSocket = new Socket(m_pSession.LocalEndPoint.AddressFamily,SocketType.Stream,ProtocolType.Tcp); m_pSocket.BeginConnect( m_pSession.m_pDataConEndPoint, delegate(IAsyncResult ar){ try{ m_pSocket.EndConnect(ar); // Log m_pSession.LogAddText("Data connection opened."); StartDataTransfer(); } catch{ WriteLine("425 Opening data connection to '" + m_pSession.m_pDataConEndPoint.ToString() + "' failed."); Dispose(); } }, null ); } }
private bool IDLE(string cmdTag,string cmdText) { /* RFC 2177 3. IDLE Command. Arguments: none Responses: continuation data will be requested; the client sends the continuation data "DONE" to end the command Result: OK - IDLE completed after client sent "DONE" NO - failure: the server will not allow the IDLE command at this time BAD - command unknown or arguments invalid The IDLE command may be used with any IMAP4 server implementation that returns "IDLE" as one of the supported capabilities to the CAPABILITY command. If the server does not advertise the IDLE capability, the client MUST NOT use the IDLE command and must poll for mailbox updates. In particular, the client MUST continue to be able to accept unsolicited untagged responses to ANY command, as specified in the base IMAP specification. The IDLE command is sent from the client to the server when the client is ready to accept unsolicited mailbox update messages. The server requests a response to the IDLE command using the continuation ("+") response. The IDLE command remains active until the client responds to the continuation, and as long as an IDLE command is active, the server is now free to send untagged EXISTS, EXPUNGE, and other messages at any time. The IDLE command is terminated by the receipt of a "DONE" continuation from the client; such response satisfies the server's continuation request. At that point, the server MAY send any remaining queued untagged responses and then MUST immediately send the tagged response to the IDLE command and prepare to process other commands. As in the base specification, the processing of any new command may cause the sending of unsolicited untagged responses, subject to the ambiguity limitations. The client MUST NOT send a command while the server is waiting for the DONE, since the server will not be able to distinguish a command from a continuation. The server MAY consider a client inactive if it has an IDLE command running, and if such a server has an inactivity timeout it MAY log the client off implicitly at the end of its timeout period. Because of that, clients using IDLE are advised to terminate the IDLE and re-issue it at least every 29 minutes to avoid being logged off. This still allows a client to receive immediate mailbox updates even though it need only "poll" at half hour intervals. Example: C: A001 SELECT INBOX S: * FLAGS (Deleted Seen) S: * 3 EXISTS S: * 0 RECENT S: * OK [UIDVALIDITY 1] S: A001 OK SELECT completed C: A002 IDLE S: + idling ...time passes; new mail arrives... S: * 4 EXISTS C: DONE S: A002 OK IDLE terminated ...another client expunges message 2 now... C: A003 FETCH 4 ALL S: * 4 FETCH (...) S: A003 OK FETCH completed C: A004 IDLE S: * 2 EXPUNGE S: * 3 EXISTS S: + idling ...time passes; another client expunges message 3... S: * 3 EXPUNGE S: * 2 EXISTS ...time passes; new mail arrives... S: * 3 EXISTS C: DONE S: A004 OK IDLE terminated C: A005 FETCH 3 ALL S: * 3 FETCH (...) S: A005 OK FETCH completed */ if(!this.IsAuthenticated){ m_pResponseSender.SendResponseAsync(new IMAP_r_ServerStatus(cmdTag,"NO","Authentication required.")); return true; } m_pResponseSender.SendResponseAsync(new IMAP_r_ServerStatus("+","idling")); TimerEx timer = new TimerEx(30000,true); timer.Elapsed += new System.Timers.ElapsedEventHandler(delegate(object sender,System.Timers.ElapsedEventArgs e){ try{ UpdateSelectedFolderAndSendChanges(); } catch{ } }); timer.Enabled = true; // Read client response. SmartStream.ReadLineAsyncOP readLineOP = new SmartStream.ReadLineAsyncOP(new byte[32000],SizeExceededAction.JunkAndThrowException); readLineOP.Completed += new EventHandler<EventArgs<SmartStream.ReadLineAsyncOP>>(delegate(object sender,EventArgs<SmartStream.ReadLineAsyncOP> e){ try{ if(readLineOP.Error != null){ LogAddText("Error: " + readLineOP.Error.Message); timer.Dispose(); return; } // Remote host closed connection. else if(readLineOP.BytesInBuffer == 0){ LogAddText("Remote host(connected client) closed IMAP connection."); timer.Dispose(); Dispose(); return; } LogAddRead(readLineOP.BytesInBuffer,readLineOP.LineUtf8); if(string.Equals(readLineOP.LineUtf8,"DONE",StringComparison.InvariantCultureIgnoreCase)){ timer.Dispose(); m_pResponseSender.SendResponseAsync(new IMAP_r_ServerStatus(cmdTag,"OK","IDLE terminated.")); BeginReadCmd(); } else{ while(this.TcpStream.ReadLine(readLineOP,true)){ if(readLineOP.Error != null){ LogAddText("Error: " + readLineOP.Error.Message); timer.Dispose(); return; } LogAddRead(readLineOP.BytesInBuffer,readLineOP.LineUtf8); if(string.Equals(readLineOP.LineUtf8,"DONE",StringComparison.InvariantCultureIgnoreCase)){ timer.Dispose(); m_pResponseSender.SendResponseAsync(new IMAP_r_ServerStatus(cmdTag,"OK","IDLE terminated.")); BeginReadCmd(); break; } } } } catch(Exception x){ timer.Dispose(); OnError(x); } }); while(this.TcpStream.ReadLine(readLineOP,true)){ if(readLineOP.Error != null){ LogAddText("Error: " + readLineOP.Error.Message); timer.Dispose(); break; } LogAddRead(readLineOP.BytesInBuffer,readLineOP.LineUtf8); if(string.Equals(readLineOP.LineUtf8,"DONE",StringComparison.InvariantCultureIgnoreCase)){ timer.Dispose(); m_pResponseSender.SendResponseAsync(new IMAP_r_ServerStatus(cmdTag,"OK","IDLE terminated.")); BeginReadCmd(); break; } } return false; }