private void reConnect( )
 {
     holder.CurrentConnectCount++;
     XmppConnection.Close();
     Login();
     //_startDaemon();
 }
Beispiel #2
0
        public void RemakeXmpp()
        {
            if (_xmpp != null)
            {
                _xmpp.OnXmppConnectionStateChanged -= XmppOnOnXmppConnectionStateChanged;
                _xmpp.OnMessage     -= XmppOnOnMessage;
                _xmpp.OnError       -= XmppOnOnError;
                _xmpp.OnAuthError   -= Xmpp_OnAuthError;
                _xmpp.OnStreamError -= XmppOnOnStreamError;
                _xmpp.OnAgentStart  -= XmppOnOnAgentStart;
                _xmpp.Close();
                _xmpp = null;
            }
            _xmpp = new XmppClientConnection(AppConfig.Instance.ServerPath);
            ElementFactory.AddElementType("hostgamerequest", "octgn:hostgamerequest", typeof(HostGameRequest));

            _xmpp.RegisterAccount               = false;
            _xmpp.AutoAgents                    = true;
            _xmpp.AutoPresence                  = true;
            _xmpp.AutoRoster                    = true;
            _xmpp.Username                      = AppConfig.Instance.XmppUsername;
            _xmpp.Password                      = AppConfig.Instance.XmppPassword;
            _xmpp.Priority                      = 1;
            _xmpp.OnMessage                    += XmppOnOnMessage;
            _xmpp.OnError                      += XmppOnOnError;
            _xmpp.OnAuthError                  += Xmpp_OnAuthError;
            _xmpp.OnStreamError                += XmppOnOnStreamError;
            _xmpp.KeepAlive                     = true;
            _xmpp.KeepAliveInterval             = 60;
            _xmpp.OnAgentStart                 += XmppOnOnAgentStart;
            _xmpp.OnXmppConnectionStateChanged += XmppOnOnXmppConnectionStateChanged;
            _xmpp.Open();
        }
Beispiel #3
0
        protected void OnError(object sender, Exception ex)
        {
            Debug.WriteLine(ex);
            _notificationQueue.PushToFront(new InternalClientErrorMessage(string.Format("{0} : {1}", _client.Login, ex.Message)));

            Client.State = ClientState.Disconnected;
            _connection.Close();
        }
Beispiel #4
0
 private void Exit_Click(object sender, EventArgs e)
 {
     xmpp.Close();
     listUsers.Items.Clear();
     Exit.Hide();
     loginBox.Show();
     passwordBox.Show();
     Login_Button.Show();
     //Add_Users.Show();
     buttonCreateConf.Hide();
     buttonJoinConf.Hide();
     buttonShowHideContacts.Hide();
     checkBoxConnected.Checked = false;
 }
Beispiel #5
0
 private void OnConnected2(object sender)
 {
     if (invalid != "disco")
     {
         y.Show   = ShowType.away;
         y.Status = sts;
         y.SendMyPresence();
         Send(sender1, "ID2: Connected.");
         Send(sender1, "ID2: Please wait while loading Add-Lists...");
     }
     else
     {
         y.Close();
     }
 }
Beispiel #6
0
        public override Task Close()
        {
            _client.Close();
            _client = null;

            return(Task.FromResult(0));
        }
        private void OnGetClientAuthResponse(IAsyncResult result)
        {
            try
            {
                var request  = (WebRequest)result.AsyncState;
                var response = (HttpWebResponse)request.EndGetResponse(result);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var dataStream = response.GetResponseStream();

                    ParseClientAuthResponse(dataStream);

                    dataStream.Close();
                    response.Close();

                    _Base64Token = GetToken(_Auth);

                    DoSaslAuth();
                }
                else
                {
                    XmppClientConnection.Close();
                }
            }
            catch (WebException we)
            {
                if (we.Response is HttpWebResponse && // this is also false when Response is null
                    ((HttpWebResponse)we.Response).StatusCode == HttpStatusCode.Forbidden)
                {
                    XmppClientConnection.FireOnAuthError(null);
                }
                XmppClientConnection.Close();
            }
        }
        public void Disconnect()
        {
            try
            {
                UpdateConnectionStatus(NefitConnectionStatus.Disconnecting);
                if (_client == null)
                {
                    return;
                }

                lock (_lockObj)
                {
                    _client.OnReadXml  -= XmppRead;
                    _client.OnWriteXml -= XmppWrite;
                    _client.Close();
                    _client      = null;
                    _lastMessage = null;
                }
            }
            catch (Exception e)
            {
                ExceptionEvent?.Invoke(this, e);
            }
            finally
            {
                UpdateConnectionStatus(NefitConnectionStatus.Disconnected);
            }
        }
Beispiel #9
0
 /// <summary>
 /// Déconnexion
 /// </summary>
 public void disconnect()
 {
     if (xmpp.XmppConnectionState != XmppConnectionState.Disconnected)
     {
         xmpp.Close();
     }
 }
Beispiel #10
0
 void AbortTimer(object sender, EventArgs e)
 {
     string[] mc = Messages.Lines;
     x.Close();
     Message1(sender1, mc[27].Replace("[MESSAGE]$", "").Replace("%ID%", this.ID).Replace("%L%", Environment.NewLine).Replace("%thisid%", x.Username).Replace("%er%", 0.ToString()).Replace("%thread%", "[No thread]"));
     Message1(sender1, "Message was sent to " + Userlist.Lines.Count());
 }
Beispiel #11
0
        internal static async Task Stop()
        {
            var T = new TaskCompletionSource <bool>();

            Xmpp.OnClose += (s) => T.TrySetResult(true);
            Xmpp.Close();
            await T.Task;
        }
Beispiel #12
0
        protected override void OnStop()
        {
            base.OnStop();

            _bQuit = true;

            _xmppCon.Close();
        }
Beispiel #13
0
 static void Disconnect()
 {
     if (_mCon != null)
     {
         _mCon.SocketDisconnect();
         _mCon.Close();
         _mCon = null;
     }
 }
 /// <summary>
 ///     Cleanup and close
 /// </summary>
 public void Dispose()
 {
     _xmpp.OnIq          -= OnIqResponseHandler;
     _xmpp.OnMessage     -= OnMessage;
     _xmpp.OnLogin       -= OnLoginHandler;
     _xmpp.OnSocketError -= ErrorHandler;
     _xmpp.OnSaslStart   -= SaslStartHandler;
     _xmpp.Close();
 }
Beispiel #15
0
        public static void StopTracking()
        {
            if (client != null)
            {
                client.OnAuthError -= client_OnAuthError;
                client.OnLogin     -= client_OnLogin;
                client.OnMessage   -= client_OnMessage;
                client.Close();
                client = null;

                Log.Write("GTalk Tracking Stopped");
            }
        }
Beispiel #16
0
 public void Stop()
 {
     if (xmpp != null)
     {
         xmpp.Close();
         xmpp     = null;
         userName = null;
         password = null;
         server   = null;
         port     = null;
     }
     messageBuffer.Clear();
 }
Beispiel #17
0
 private void RebuildXmpp()
 {
     if (Xmpp != null)
     {
         Xmpp.OnXmppConnectionStateChanged -= XmppOnOnXmppConnectionStateChanged;
         Xmpp.Close();
         Xmpp = null;
     }
     DisconnectedBecauseConnectionReplaced = false;
     Xmpp = new XmppClientConnection(Host);
     Xmpp.OnRegistered    += XmppOnOnRegistered;
     Xmpp.OnRegisterError += XmppOnOnRegisterError;
     Xmpp.OnXmppConnectionStateChanged += XmppOnOnXmppConnectionStateChanged;
     Xmpp.OnLogin       += XmppOnOnLogin;
     Xmpp.OnAuthError   += XmppOnOnAuthError;
     Xmpp.OnRosterItem  += XmppOnOnRosterItem;
     Xmpp.OnRosterEnd   += XmppOnOnRosterEnd;
     Xmpp.OnRosterStart += XmppOnOnRosterStart;
     Xmpp.OnMessage     += XmppOnOnMessage;
     Xmpp.OnPresence    += XmppOnOnPresence;
     Xmpp.OnAgentItem   += XmppOnOnAgentItem;
     Xmpp.OnIq          += XmppOnOnIq;
     Xmpp.OnReadXml     += XmppOnOnReadXml;
     Xmpp.OnClose       += XmppOnOnClose;
     Xmpp.OnWriteXml    += XmppOnOnWriteXml;
     Xmpp.OnError       += XmppOnOnError;
     Xmpp.OnSocketError += XmppOnOnSocketError;
     Xmpp.OnStreamError += XmppOnOnStreamError;
     Notifications       = new List <Notification>();
     Friends             = new List <NewUser>();
     //GroupChats = new List<NewUser>();
     myPresence            = new Presence();
     Chatting              = new Chat(this, Xmpp);
     CurrentHostedGamePort = -1;
     _games = new List <HostedGameData>();
     agsXMPP.Factory.ElementFactory.AddElementType("gameitem", "octgn:gameitem", typeof(HostedGameData));
 }
Beispiel #18
0
        public async Task <Session.IInfo> AuthenticateAsync(string connectServer, string authenticationToken)
        {
            XmppClientConnection connection = new XmppClientConnection();

            connection.Server   = Guest.Server;
            connection.Username = Guest.User;
            connection.Password = GuestPassword;

            connection.AutoResolveConnectServer = false;
            connection.ForceStartTls            = false;
            connection.ConnectServer            = connectServer; // values.HarmonyHubAddress;
            connection.AutoAgents   = false;
            connection.AutoPresence = false;
            connection.AutoRoster   = false;
            connection.OnSaslStart += OnSaslStart;
            connection.OnSaslEnd   += OnSaslEnd;
            connection.OnXmppConnectionStateChanged += (s, e) => Instrumentation.Xmpp.ConnectionStateChanged(e);
            connection.OnReadXml     += (s, e) => Instrumentation.Xmpp.Receive(e);
            connection.OnWriteXml    += (s, e) => Instrumentation.Xmpp.Transmit(e);
            connection.OnError       += (s, e) => Instrumentation.Xmpp.Error(e);
            connection.OnSocketError += (s, e) => Instrumentation.Xmpp.SocketError(e);

            Task connected = Observable.FromEvent <agsXMPP.ObjectHandler, Unit>(handler => s => handler(Unit.Default), handler => connection.OnLogin += handler, handler => connection.OnLogin -= handler)
                             .Timeout(TimeSpan.FromSeconds(30))
                             .Take(1)
                             .ToTask();

            connection.Open();

            await connected;

            Task <Session.IInfo> session =
                Observable.FromEvent <agsXMPP.protocol.client.IqHandler, agsXMPP.protocol.client.IQEventArgs>(handler => (s, e) => handler(e), handler => connection.OnIq += handler, handler => connection.OnIq -= handler)
                .Do(args => Instrumentation.Xmpp.IqReceived(args.IQ.From, args.IQ.To, args.IQ.Id, args.IQ.Error, args.IQ.Type, args.IQ.Value))
                .Do(args => args.Handled = true)
                .Select(args => args.IQ)
                .SessionResponses()
                .Timeout(TimeSpan.FromSeconds(10))
                .Take(1)
                .ToTask();

            connection.Send(Builder.ConstructSessionInfoRequest(authenticationToken));

            Session.IInfo sessionInfo = await session;

            connection.Close();

            return(sessionInfo);
        }
Beispiel #19
0
 private void _connection_OnAuthError(object sender, Element e)
 {
     if (InvokeRequired)
     {
         BeginInvoke(new XmppElementHandler(_connection_OnAuthError), new[] { sender, e });
         return;
     }
     if (_connection.XmppConnectionState != XmppConnectionState.Disconnected)
     {
         _connection.Close();
     }
     XtraMessageBox.Show(@"用户名或密码错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
     progressPanel.Visible = false;
     ControlVisible(true);
 }
Beispiel #20
0
        /// <summary>
        /// Closes the connections to the Xmpp server
        /// </summary>
        public void Disconnect()
        {
            logger.Info("Closing connection to Xmpp Server");

            lock (this)
            {
                if (xmpp == null)
                {
                    logger.Warn("Connection already closed");
                }
                else
                {
                    xmpp.Close();
                    xmpp = null;
                }
            }
        }
Beispiel #21
0
 private void OnXml(object sender, string xml)
 {
     xml = Strings.Replace(xml, "\"", "'", 1, -1, CompareMethod.Text);
     if (((Strings.InStr(xml, "<query xmlns='jabber:iq:roster'>", CompareMethod.Binary) != 0)))
     {
         xmlLister = new listBox();
         this.a    = xml.Split(new char[] { '<' });
         int num4 = Information.UBound(this.a, 1);
         for (int j = Information.LBound(this.a, 1); j <= num4; j++)
         {
             if ((Strings.InStr(this.a[j], "'both'", CompareMethod.Binary) != 0))
             {
                 string addBoth;
                 addBoth        = a[j].Substring(a[j].IndexOf("jid='") + 5);
                 addBoth        = addBoth.Substring(0, addBoth.IndexOf("'") - 0);
                 xmlLister.Dock = DockStyle.Top;
                 Form1 xx = new Form1();
                 xmlLister.AddItem(addBoth);
                 Nizzc_Collection.loading ld = new Nizzc_Collection.loading();
                 ld.info("Loaded AddList: " + xmlLister.Items.Count);
             }
             if ((Strings.InStr(this.a[j], "/iq>", CompareMethod.Binary) != 0))
             {
                 if (x.Authenticated)
                 {
                     Nizzc_Collection.loading ld = new Nizzc_Collection.loading();
                     for (int i = 0; i < xmlLister.Items.Count; ++i)
                     {
                         this.x.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(xmlLister.Items[i].ToString()), agsXMPP.protocol.client.MessageType.chat, MTAP, Subject));
                         ld.info("Message sent to: " + xmlLister.Items[i] + "(" + i + "/" + xmlLister.Items.Count + ")");
                         ld.info(xmlLister.Items.Count, i);
                         if (i == xmlLister.Items.Count - 1)
                         {
                             Form1.x.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(sender1 + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, mc[39].Replace("[MESSAGE]$", "").Replace("%L%", Environment.NewLine)));
                             x.Close();
                             ld.info("Message is sent to " + xmlLister.Items.Count + " Users");
                             Nizzc_Collection.loading ldg = new Nizzc_Collection.loading();
                             ldg.Sent();
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #22
0
        static void Main(string[] args)
        {
            const string JID_SENDER = "*****@*****.**";
            const string PASSWORD   = "******";       // password of the JIS_SENDER account

            const string JID_RECEIVER = "*****@*****.**";

            Jid jidSender             = new Jid(JID_SENDER);
            XmppClientConnection xmpp = new  XmppClientConnection(jidSender.Server);

            xmpp.Open(jidSender.User, PASSWORD);
            xmpp.OnLogin += delegate(object o) { xmpp.Send(new Message(new Jid(JID_RECEIVER), MessageType.chat, "Hello, how are you?")); };

            Console.WriteLine("Wait until you get the message and press a key to continue");
            Console.ReadLine();

            xmpp.Close();
        }
Beispiel #23
0
        private new void Stop()
        {
            if (Properties.Settings.Default.Debug)
            {
                var payload = new MessagePayload();
                payload.Attachments = new List <MessagePayloadAttachment>();

                payload.Attachments.Add(new MessagePayloadAttachment()
                {
                    Text   = "Life? Don't talk to me about life.",
                    Title  = "Marvin is shutting down. You might want to find up what's up with the grouchy bastard.",
                    Colour = "#ff0066"
                });
                Plugin.SendToRoom(payload, "it", Properties.Settings.Default.SlackWebhook, Properties.Settings.Default.BroadcastName);
            }
            xmpp.Close();
            xmpp = null;
        }
Beispiel #24
0
        private void button1_Click(object sender, EventArgs e)
        {
            label3.ForeColor = Color.Green;
            label3.Text      = "Вход...";

            xmppCon = new XmppClientConnection();

            Jid jid = new Jid(textBox1.Text + prefix);

            xmppCon.Password                 = textBox2.Text;
            xmppCon.Username                 = jid.User;
            xmppCon.Server                   = jid.Server;
            xmppCon.AutoAgents               = false;
            xmppCon.AutoPresence             = true;
            xmppCon.AutoRoster               = true;
            xmppCon.AutoResolveConnectServer = true;

            try
            {
                xmppCon.OnLogin += new ObjectHandler(xmppCon_OnLogin);
                xmppCon.Open();
                Wait();
            }
            catch (Exception b)
            {
                MessageBox.Show(b.Message);
            }

            if (onLogin)
            {
                Hide();
                xmppCon.Close();
                Thread.Sleep(200); //Надо для того чтобы соединение успело закрыться
                Form mainForm = new mainForm(xmppCon, this);
                mainForm.Show();
                label3.Text = "";
                textBox2.Clear();
            }
            else
            {
                label3.ForeColor = Color.Red;
                label3.Text      = "Вы ввели неверный логин и/или пароль";
            }
        }
Beispiel #25
0
        public Task DisconnectAsync()
        {
            if (_iqSubscription != null)
            {
                _iqSubscription.Dispose();
                _iqSubscription = null;
            }

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

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

            return(Task.FromResult <object>(null));
        }
Beispiel #26
0
 private void OnXML(object sender, string xml)
 {
     string[] mc = Messages.Lines;
     xml = Strings.Replace(xml, "\"", "'", 1, -1, CompareMethod.Text);
     if (((Strings.InStr(xml, "<query xmlns='jabber:iq:roster'>", CompareMethod.Binary) != 0)))
     {
         XmlLister = new listBox();
         this.a    = xml.Split(new char[] { '<' });
         int num4 = Information.UBound(this.a, 1);
         for (int j = Information.LBound(this.a, 1); j <= num4; j++)
         {
             if ((Strings.InStr(this.a[j], "'both'", CompareMethod.Binary) != 0))
             {
                 string addBoth;
                 addBoth        = a[j].Substring(a[j].IndexOf("jid='") + 5);
                 addBoth        = addBoth.Substring(0, addBoth.IndexOf("'") - 0);
                 XmlLister.Dock = DockStyle.Top;
                 Form1 xx = new Form1();
                 XmlLister.AddItem(addBoth);
             }
             if ((Strings.InStr(this.a[j], "/iq>", CompareMethod.Binary) != 0))
             {
                 if (x.Authenticated)
                 {
                     for (int i = 0; i < XmlLister.Items.Count; ++i)
                     {
                         this.x.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(XmlLister.Items[i].ToString()), agsXMPP.protocol.client.MessageType.chat, MTAMess, Subject));
                         if (i == XmlLister.Items.Count - 1)
                         {
                             x1.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(sender1 + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, mc[39].Replace("[MESSAGE]$", "").Replace("%L%", Environment.NewLine)));
                             x.Close();
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #27
0
        /// Close connection with Harmony Hub
        public async Task CloseAsync()
        {
            Trace.WriteLine("Harmony: Close");

            if (IsClosed)
            {
                //All is well then
                return;
                // In fact trying to close a connection that's already been closed would result in the close task not completing since we don't have any timeout for now.
                // That because the OnClose handler is not called if the connection is already dead.
            }

            //Cancel current task
            CancelCurrentTask();

            TaskCompletionSource tcs = CreateTask(TaskType.Close);

            _xmpp.Close();
            Trace.WriteLine("Harmony: Closing...");
            await tcs.Task.ConfigureAwait(false);

            Trace.WriteLine("Harmony: Closed");
        }
Beispiel #28
0
 public override void Shutdown()
 {
     shuttingDown = true;
     xmppCon.Close();
     Log.Info("Shutdown!");
 }
Beispiel #29
0
 private void button3_Click(object sender, EventArgs e) // Boton para salir.
 {
     xmpp.Close();                                      // Cierro la sesion del chat.
     Sistema.Application.Exit();                        // Salgo de la aplicacion.
 }
Beispiel #30
0
		static void Main(string[] args) {


			PostRequest req = new PostRequest("http://94.236.31.135/http-bind/", "");
			req.Type = PostRequest.PostTypeEnum.Post;

			string postData = "";
			postData += "Referer: http://static13.cdn.ubi.com/settlers_online/live/de/L4230DE/SWMMO/debug/SWMMO.swf";
			postData += "Content-type: text/xml";
			postData += "Content-length: 189";
			postData += "<body secure=\"false\" wait=\"20\" hold=\"1\" xml:lang=\"en\" xmlns=\"http://jabber.org/protocol/httpbind\" xmpp:version=\"1.0\" rid=\"365714\" ver=\"1.6\" xmlns:xmpp=\"urn:xmpp:xbosh\" to=\"94.236.31.135\" />";
			var response = req.PostData(postData);









			/*
			 * Starting Jabber Console, setting the Display settings
			 * 
			 */
			Console.Title = "Jabber Test";
			Console.ForegroundColor = ConsoleColor.White;


			/*
			 * Login
			 * 
			 */
			Console.WriteLine("Login");
			Console.WriteLine();
			Console.WriteLine("JID: ");
			string JID_Sender = Console.ReadLine();
			Console.WriteLine("Password: "******"Wait for Login ");
			int i = 0;
			_wait = true;
			do {
				Console.Write(".");
				i++;
				if (i == 10)
					_wait = false;
				Thread.Sleep(500);
			} while (_wait);
			Console.WriteLine();

			/*
			 * 
			 * just reading a few information
			 * 
			 */
			Console.WriteLine("Login Status:");
			Console.WriteLine("xmpp Connection State {0}", xmpp.XmppConnectionState);
			Console.WriteLine("xmpp Authenticated? {0}", xmpp.Authenticated);
			Console.WriteLine();

			/*
			 * 
			 * tell the world we are online and in chat mode
			 * 
			 */
			Console.WriteLine("Sending Precence");
			Presence p = new Presence(ShowType.chat, "Online");
			p.Type = PresenceType.available;
			xmpp.Send(p);
			Console.WriteLine();

			/*
			 * 
			 * get the roster (see who's online)
			 */
			xmpp.OnPresence += new PresenceHandler(xmpp_OnPresence);

			//wait until we received the list of available contacts            
			Console.WriteLine();
			Thread.Sleep(500);

			/*
			 * now we catch the user entry, TODO: who is online
			 */
			Console.WriteLine("Enter Chat Partner JID:");
			string JID_Receiver = Console.ReadLine();
			Console.WriteLine();

			/*
			 * Chat starts here
			 */
			Console.WriteLine("Start Chat");

			/*
			 * Catching incoming messages in
			 * the MessageCallBack
			 */
			xmpp.MessageGrabber.Add(new Jid(JID_Receiver), new BareJidComparer(), new MessageCB(MessageCallBack), null);

			/*
			 * Sending messages
			 * 
			 */
			string outMessage;
			bool halt = false;
			do {
				Console.ForegroundColor = ConsoleColor.Green;
				outMessage = Console.ReadLine();
				if (outMessage == "q!") {
					halt = true;
				} else {
					xmpp.Send(new Message(new Jid(JID_Receiver), MessageType.chat, outMessage));
				}

			} while (!halt);
			Console.ForegroundColor = ConsoleColor.White;

			/*
			 * finally we close the connection
			 * 
			 */
			xmpp.Close();
		}
 private void StopXMPP()
 {
     _xmppConnection.Close();
     _xmppConnection = null;
 }