/// <summary> /// Creates a new stream connection for XMPP communication /// </summary> public Session(SecurableTcpClient tcpClient) { this.tcpClient = tcpClient; // Buffer for incoming data readBuff = new byte[READ_MAX]; // Need to parse incoming stuff into stanzas streamParser = new XMLStreamParser(); // Wire up some evens for when new things come down the pipe streamParser.OnNewXmlProtocolElement += new XmlProtocolElementHandler(streamParser_OnNewXmlProtocolElement); streamParser.OnStreamBegin += new XmlProtocolElementHandler(streamParser_OnStreamBegin); streamParser.OnStreamEnd += new XmlProtocolElementHandler(streamParser_OnStreamEnd); // Start in the Offline state setState(SessionState.Offline); }
/// <summary> /// Closes the network connection. /// </summary> private void closeTcpClient() { // Enter the offline state and close the connection setState(AccountManagerState.Offline); if(tcpClient != null) { tcpClient.Close(); tcpClient = null; } }