Ejemplo n.º 1
0
        public XmppServerConnection()
        {
            //SessionId = null;
            streamParser = new XmppStreamParser();

            streamParser.OnStreamStart   += streamParser_OnStreamStart;
            streamParser.OnStreamEnd     += streamParser_OnStreamEnd;
            streamParser.OnStreamElement += streamParser_OnStreamElement;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   Closes the connection
        /// </summary>
        public override void Close()
        {
            if (!IsDisposed)
            {
                try
                {
                    Send(EndStream);
                }
                // TODO: empty try-catch bad, martial arts good
// ReSharper disable EmptyGeneralCatchClause
                catch
// ReSharper restore EmptyGeneralCatchClause
                {
                }
                finally
                {
                    if (tlsProceedEvent != null)
                    {
                        tlsProceedEvent.Set();
                        tlsProceedEvent = null;
                    }

                    if (networkStream != null)
                    {
                        networkStream.Dispose();
                        networkStream = null;
                    }

                    if (socket != null)
                    {
                        socket.Close();
                        socket = null;
                    }

                    if (inputBuffer != null)
                    {
                        inputBuffer.Dispose();
                        inputBuffer = null;
                    }

                    if (parser != null)
                    {
                        parser.Dispose();
                        parser = null;
                    }
                }

                base.Close();
            }
        }
Ejemplo n.º 3
0
        public Session(GJTalkServer server, Socket socket)
        {
            this.server = server;
            this.socket = socket;
            // server.SessionManager.Add(this);
            readCallback = new AsyncCallback(OnRead);

            buffer = new byte[buff_size];
            streamParser = new XmppStreamParser();
            streamParser.OnError += streamParser_OnError;
            streamParser.OnStreamElement += streamParser_OnStreamElement;
            streamParser.OnStreamEnd += streamParser_OnStreamEnd;
            streamParser.OnStreamStart += streamParser_OnStreamStart;
            BeginRead();
            Roster = new Xmpp.Roster.Roster();
            Groups = new List<BuddyGroup>();
            Console.WriteLine("New Session");
        }
Ejemplo n.º 4
0
        public Session(GJTalkServer server, Socket socket)
        {
            this.server = server;
            this.socket = socket;
            // server.SessionManager.Add(this);
            readCallback = new AsyncCallback(OnRead);

            buffer                        = new byte[buff_size];
            streamParser                  = new XmppStreamParser();
            streamParser.OnError         += streamParser_OnError;
            streamParser.OnStreamElement += streamParser_OnStreamElement;
            streamParser.OnStreamEnd     += streamParser_OnStreamEnd;
            streamParser.OnStreamStart   += streamParser_OnStreamStart;
            BeginRead();
            Roster = new Xmpp.Roster.Roster();
            Groups = new List <BuddyGroup>();
            Console.WriteLine("New Session");
        }
Ejemplo n.º 5
0
        /// <summary>
        ///   Closes the connection
        /// </summary>
        public override void Close()
        {
            if (!IsDisposed)
            {
                try
                {
                    Send(EndStream);
                }
                    // TODO: empty try-catch bad, martial arts good
            // ReSharper disable EmptyGeneralCatchClause
                catch
            // ReSharper restore EmptyGeneralCatchClause
                {
                }
                finally
                {
                    if (tlsProceedEvent != null)
                    {
                        tlsProceedEvent.Set();
                        tlsProceedEvent = null;
                    }

                    if (networkStream != null)
                    {
                        networkStream.Dispose();
                        networkStream = null;
                    }

                    if (socket != null)
                    {
                        socket.Close();
                        socket = null;
                    }

                    if (inputBuffer != null)
                    {
                        inputBuffer.Dispose();
                        inputBuffer = null;
                    }

                    if (parser != null)
                    {
                        parser.Dispose();
                        parser = null;
                    }
                }

                base.Close();
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 ///   Initializes the connection instance
 /// </summary>
 private void Initialize()
 {
     inputBuffer = new XmppMemoryStream();
     parser = new XmppStreamParser(inputBuffer);
     tlsProceedEvent = new AutoResetEvent(false);
 }
Ejemplo n.º 7
0
 /// <summary>
 ///   Initializes the connection instance
 /// </summary>
 private void Initialize()
 {
     inputBuffer     = new XmppMemoryStream();
     parser          = new XmppStreamParser(inputBuffer);
     tlsProceedEvent = new AutoResetEvent(false);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Closes the connection
        /// </summary>
        public override void Close()
        {
            if (!this.IsDisposed)
            {
                try
                {
                    this.Send(EndStream);
                }
                catch
                {
                }
                finally
                {
                    if (this.tlsProceedEvent != null)
                    {
                        this.tlsProceedEvent.Set();
                        this.tlsProceedEvent = null;
                    }

                    if (this.networkStream != null)
                    {
                        this.networkStream.Dispose();
                        this.networkStream = null;
                    }

                    if (this.socket != null)
                    {
                        this.socket.Close();
                        this.socket = null;
                    }

                    if (this.inputBuffer != null)
                    {
                        this.inputBuffer.Dispose();
                        this.inputBuffer = null;
                    }

                    if (this.parser != null)
                    {
                        this.parser.Dispose();
                        this.parser = null;
                    }
                }

                base.Close();
            }
        }