/// <summary>
        ///   Initializes a new instance of the <see cref = "XmppSession" /> class
        /// </summary>
        public XmppSession()
        {
            State                     = XmppSessionState.LoggedOut;
            avatarStorage             = new AvatarStorage();
            chats                     = new Dictionary <string, XmppChat>();
            syncObject                = new object();
            connection                = new XmppConnection();
            serviceDiscovery          = new XmppServiceDiscovery(this);
            personalEventing          = new XmppPersonalEventing(this);
            activity                  = new XmppActivity(this);
            clientCapabilitiesStorage = new XmppClientCapabilitiesStorage();
            roster                    = new XmppRoster(this);

            avatarStorage.Load();
            clientCapabilitiesStorage.Load();
        }
        /// <summary>
        ///   Closes the Session
        /// </summary>
        public IXmppSession Close()
        {
            if (connection != null &&
                (connection.State == XmppConnectionState.Opening ||
                 connection.State == XmppConnectionState.Open))
            {
                try
                {
                    State = XmppSessionState.LoggingOut;

                    if (connection.State == XmppConnectionState.Open)
                    {
                        // Save session configuration
                        AvatarStorage.Save();

                        // Change presence to unavailable
                        SetUnavailable();

                        // Clear all chats
                        chats.Clear();
                    }

                    // Close connection
                    connection.Close();

                    // Unwire XmppConnection events
                    Unsubscribe();
                }
                catch
                {
                }
                finally
                {
                    State = XmppSessionState.LoggedOut;
                }
            }

            return(this);
        }
Exemple #3
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "XmppSession" /> class
        /// </summary>
        public XmppSession()
        {
            State = XmppSessionState.LoggedOut;
            avatarStorage = new AvatarStorage();
            chats = new Dictionary<string, XmppChat>();
            syncObject = new object();
            connection = new XmppConnection();
            serviceDiscovery = new XmppServiceDiscovery(this);
            personalEventing = new XmppPersonalEventing(this);
            activity = new XmppActivity(this);
            clientCapabilitiesStorage = new XmppClientCapabilitiesStorage();
            roster = new XmppRoster(this);

            avatarStorage.Load();
            clientCapabilitiesStorage.Load();
        }