예제 #1
0
 public void Close()
 {
     if (IsConnected())
     {
         jabberClient.Close();
     }
 }
예제 #2
0
        public override void Reconnect(FrontendManager fm)
        {
            Trace.Call(fm);

            _JabberClient.Close();
            _JabberClient.Connect();
        }
예제 #3
0
        static string serverKey = ""; //replace with your server key
        //static string testDeviceId =
        static void Main(string[] args)
        {
            JabberClient jabberClient1 = new JabberClient();

            jabberClient1.Server      = "gcm.googleapis.com";
            jabberClient1.NetworkHost = "fcm-xmpp.googleapis.com";
            jabberClient1.Port        = 5236;

            jabberClient1.SSL = true;
            //xmppClient.OldStyleSsl = true;

            jabberClient1.User     = senderId;  // your sender id
            jabberClient1.Password = serverKey; // your server key

            jabberClient1.AutoRoster   = false;
            jabberClient1.AutoPresence = false;

            jabberClient1.OnMessage    += new MessageHandler(jabberClient1_OnMessage);
            jabberClient1.OnDisconnect += new bedrock.ObjectHandler(jabberClient1_OnDisconnect);
            jabberClient1.OnError      += new bedrock.ExceptionHandler(jabberClient1_OnError);
            jabberClient1.OnAuthError  += new jabber.protocol.ProtocolHandler(jabberClient1_OnAuthError);
            jabberClient1.OnReadText   += new bedrock.TextHandler(jc_OnReadText);
            jabberClient1.OnWriteText  += new bedrock.TextHandler(jc_OnWriteText);

            jabberClient1.Connect();

            Console.WriteLine("Press return key to exit the application");
            Console.ReadLine();

            jabberClient1.Close();
        }
예제 #4
0
        private void btnDiconnect_Click(object sender, EventArgs e)
        {
            client?.Close();

            btnConnect.Enabled    = true;
            btnDisconnect.Enabled = false;
        }
예제 #5
0
 public void Disconnect()
 {
     Logger.Info(string.Format("Disconnecting from '{0}'", _jabberClient.Server));
     _jabberClient.Close();
     _serviceStarted = false;
     _thread.Join(5000);
 }
예제 #6
0
        public void Disconnect()
        {
            // FIXME: This is a jabber-net bug!
            if (ConnectionState == AccountConnectionState.Connecting)
            {
                Console.Error.WriteLine("Can't disconnect while still connecting!");
                return;
            }

            m_Client.Close();
            ConnectionState = AccountConnectionState.Disconnected;
        }
예제 #7
0
        public void Disconnect()
        {
            // удаляем чаты
            foreach (var chat in _chatRooms)
            {
                chat.StateChanged -= ichat_StateChanged;
                chat.Dispose();
            }
            _chatRooms.Clear();
            // удаляем комнаты
            foreach (Room r in _rooms.Values)
            {
                r.Leave(null);
            }
            _rooms.Clear();

            _connected = false;
            if (_disco != null)
            {
                _disco.Dispose();
            }
            if (_conference != null)
            {
                _conference.Dispose();
            }
            if (_roster != null)
            {
                _roster.Dispose();
            }
            if (_jc == null)
            {
                return;
            }

            _jc.Close();
            UnSubscribe();
            _jc.Dispose();
            _jc = null;
        }
예제 #8
0
        public Class1(string[] args)
        {
            JabberClient jc = new JabberClient();

            jc.OnReadText    += new bedrock.TextHandler(jc_OnReadText);
            jc.OnWriteText   += new bedrock.TextHandler(jc_OnWriteText);
            jc.OnError       += new bedrock.ExceptionHandler(jc_OnError);
            jc.OnStreamError += new jabber.protocol.ProtocolHandler(jc_OnStreamError);

            jc.AutoReconnect = 3f;

            GetOpt go = new GetOpt(this);

            try
            {
                go.Process(args);
            }
            catch (ArgumentException)
            {
                go.UsageExit();
            }

            if (untrustedOK)
            {
                jc.OnInvalidCertificate += new System.Net.Security.RemoteCertificateValidationCallback(jc_OnInvalidCertificate);
            }

            JID j = new JID(jid);

            jc.User         = j.User;
            jc.Server       = j.Server;
            jc.NetworkHost  = networkHost;
            jc.Port         = port;
            jc.Resource     = "Jabber.Net Console Client";
            jc.Password     = pass;
            jc.AutoStartTLS = TLS;
            jc.AutoPresence = initialPresence;

            if (certificateFile != null)
            {
                jc.SetCertificateFile(certificateFile, certificatePass);
                Console.WriteLine(jc.LocalCertificate.ToString(true));
            }

            if (boshURL != null)
            {
                jc[Options.POLL_URL]        = boshURL;
                jc[Options.CONNECTION_TYPE] = ConnectionType.HTTP_Binding;
            }

            if (register)
            {
                jc.AutoLogin        = false;
                jc.OnLoginRequired +=
                    new bedrock.ObjectHandler(jc_OnLoginRequired);
                jc.OnRegisterInfo += new RegisterInfoHandler(this.jc_OnRegisterInfo);
                jc.OnRegistered   += new IQHandler(jc_OnRegistered);
            }

            CapsManager cm = new CapsManager();

            cm.Stream = jc;
            cm.Node   = "http://cursive.net/clients/ConsoleClient";

            Console.WriteLine("Connecting");
            jc.Connect();
            Console.WriteLine("Connected");

            string line;

            while ((line = Console.ReadLine()) != null)
            {
                if (line == "/clear")
                {
                    // Hm.... I wonder if this works on windows.
                    Console.Write("\x1b[H\x1b[2J");
                    continue;
                }
                if ((line == "/q") || (line == "/quit"))
                {
                    jc.Close();
                    break;
                }
                if (line.Trim() == "")
                {
                    continue;
                }
                try
                {
                    if (line == "</stream:stream>")
                    {
                        jc.Write(line);
                    }
                    else
                    {
                        // TODO: deal with stanzas that span lines... keep
                        // parsing until we have a full "doc".
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(line);
                        XmlElement elem = doc.DocumentElement;
                        if (elem != null)
                        {
                            jc.Write(elem);
                        }
                    }
                }
                catch (XmlException ex)
                {
                    Console.WriteLine("Invalid XML: " + ex.Message);
                }
            }
        }
예제 #9
0
 /// <summary>Logs out of the Xmpp Server.</summary>
 public void Logout()
 {
     _jc.Close();
 }
예제 #10
0
 public void Dispose()
 {
     _jc.Close();
 }
예제 #11
0
 public void Disconnect()
 {
     c.Close(true);
 }