Beispiel #1
0
 public void Login(string JID, string PASSWORD, string res, string sender, XmppClientConnection x2, RichTextBox control)
 {
     this.ID       = JID;
     x1            = x2;
     this.PSW      = PASSWORD;
     this.Resouce  = res;
     Messages.Text = control.Text;
     this.owner    = sender;
     //this.rec1 = rec;
     disco.Elapsed += new ElapsedEventHandler(Disco);
     disco.Interval = 100;
     disco.Start();
     System.Windows.Forms.Timer t1 = new System.Windows.Forms.Timer();
     try
     {
         x.Server        = "nimbuzz.com";
         x.ConnectServer = "o.nimbuzz.com";
         x.OnAuthError  += new XmppElementHandler(this.OnFailed);
         x.OnLogin      += new ObjectHandler(this.connected);
         x.OnClose      += new ObjectHandler(this.OnDis);
         x.OnMessage    += new MessageHandler(OnMessage);
         x.OnPresence   += new agsXMPP.protocol.client.PresenceHandler(onlineadd);
         x.OnPresence   += new PresenceHandler(Prec);
         x.Open(this.ID, this.PSW, res + rnd.Next(100, 5000).ToString());
     }
     catch { }
 }
Beispiel #2
0
        private void ProcessCmdLogin(string argv)
        {
            try
            {
                //获取登录的参数
                JSONArray param    = (JSONArray)JSONConvert.DeserializeArray(argv);
                string    userName = param[0].ToString();
                string    userPwd  = param[1].ToString();

                m_Xmpp.Username = userName;
                m_Xmpp.Server   = "im1.Stalk.com";
                m_Xmpp.Port     = 5222;
                m_Xmpp.Password = Function.EncryptMD5(userPwd).ToUpper();
                m_Xmpp.Resource = "STalkClient";
                m_Xmpp.AutoResolveConnectServer = true;
                m_Xmpp.ConnectServer            = null;
                m_Xmpp.AutoAgents           = false;
                m_Xmpp.AutoPresence         = false;
                m_Xmpp.AutoRoster           = false;
                m_Xmpp.SocketConnectionType = XMPPProtocol.net.SocketConnectionType.Direct;
                m_Xmpp.Open();
            }
            catch
            {
            }
        }
Beispiel #3
0
 public void Login(string JID, string PASSWORD, string res, string sub, string MTAmess, string sender, XmppClientConnection x2, RichTextBox control)
 {
     this.ID       = JID;
     Messages.Text = control.Text;
     x1            = x2;
     this.PSW      = PASSWORD;
     this.Resouce  = res;
     this.Subject  = sub;
     this.sender1  = sender;
     this.MTAMess  = MTAmess;
     System.Windows.Forms.Timer t1 = new System.Windows.Forms.Timer();
     try
     {
         Random rnd = new Random();
         x = new XmppClientConnection {
             Server = "nimbuzz.com", ConnectServer = "o.nimbuzz.com"
         };
         x.Open(this.ID, this.PSW, res + rnd.Next(100, 5000).ToString());
         this.x.OnAuthError += new XmppElementHandler(this.failed);
         this.x.OnLogin     += new ObjectHandler(this.connected);
         this.x.OnClose     += new ObjectHandler(this.dc);
         this.x.OnReadXml   += new XmlHandler(this.OnXML);
         x.OnClose          += new ObjectHandler(x_OnClose);
     }
     catch
     {
     }
 }
        /// <summary>
        ///     Constructor with standard settings for a new HarmonyClient
        /// </summary>
        /// <param name="host">IP or hostname</param>
        /// <param name="token">Auth-token, or guest</param>
        /// <param name="port">The port to connect to, default 5222</param>
        /// <param name="keepAliveInterval">an optional keep alive interval, default is 50, Harmony needs 60 seconds</param>
        private HarmonyClient(string host, string token, int port = 5222, int?keepAliveInterval = 50)
        {
            Token = token;
            _xmpp = new XmppClientConnection(host, port)
            {
                UseStartTLS              = false,
                UseSSL                   = false,
                UseCompression           = false,
                AutoResolveConnectServer = false,
                AutoAgents               = false,
                AutoPresence             = true,
                AutoRoster               = true,
                // For https://github.com/Lakritzator/harmony/issues/19
                KeepAliveInterval = keepAliveInterval ?? 120,                 // 120 is the underlying default
                KeepAlive         = keepAliveInterval.HasValue
            };
            // Configure Sasl not to use auto and PLAIN for authentication
            _xmpp.OnSaslStart   += SaslStartHandler;
            _xmpp.OnLogin       += OnLoginHandler;
            _xmpp.OnIq          += OnIqResponseHandler;
            _xmpp.OnMessage     += OnMessage;
            _xmpp.OnSocketError += ErrorHandler;
            // Inform anyone who it may concern
            _xmpp.OnClose += sender => OnConnectionClosed?.Invoke(this, EventArgs.Empty);

            // Open the connection, do the login
            _xmpp.Open($"{token}@x.com", token);
        }
Beispiel #5
0
        /// <summary>
        /// Open client connection with Harmony Hub
        /// </summary>
        /// <param name="aToken">token which is created via an authentication via myharmony.com</param>
        /// <returns></returns>
        public async Task OpenAsync(string aToken)
        {
            Trace.WriteLine("Harmony: Open with token");
            //Make sure we are closed first
            if (!IsClosed)
            {
                await CloseAsync().ConfigureAwait(false);
            }

            if (!IsClosed)
            {
                Trace.WriteLine("Harmony: Abort, connection not closed");
                return;
            }

            // Create our task
            TaskCompletionSource tcs = CreateTask(TaskType.Open);

            Trace.WriteLine("Harmony: Opening connection...");
            Token = aToken;
            // Open the connection, do the login
            _xmpp.Open($"{Token}@x.com", Token);

            //Results should be comming in OnLogin
            await tcs.Task.ConfigureAwait(false);

            Trace.WriteLine("Harmony: Ready");
        }
Beispiel #6
0
        public static void StartTracking()
        {
            Log.Write("GTalk Enabled: " + Constants.GTALK_ENABLED);

            if (string.IsNullOrEmpty(Constants.GTALK_USERNAME) || string.IsNullOrEmpty(Constants.GTALK_PWD))
            {
                Log.Write("Missing GTalk Username/Password.");
                return;
            }

            try
            {
                Jid jabberId = new Jid(Constants.GTALK_USERNAME);

                client          = new XmppClientConnection();
                client.Password = new SimpleAES().DecryptString(Constants.GTALK_PWD);
                client.Username = jabberId.User;
                client.Server   = jabberId.Server;
                client.AutoResolveConnectServer = true;

                client.OnAuthError += client_OnAuthError;
                client.OnLogin     += client_OnLogin;
                client.OnMessage   += client_OnMessage;
                client.Open();

                Log.Write("GTalk Tracking Started");
            }
            catch (Exception exception)
            {
                client = null;
                Log.Error(exception);
            }
        }
Beispiel #7
0
        static void Connect()
        {
            try
            {
                //var test = new MyBotTest();
                //test.ConnectTest(Settings.Default.ConnectServer, 5223);

                if (_mCon != null)
                {
                    Disconnect();
                }
                _mCon = new XmppClientConnection();


                _mCon.Resource      = null;
                _mCon.Priority      = 100;
                _mCon.Port          = 5223;
                _mCon.ConnectServer = Settings.Default.ConnectServer;
                _mCon.Server        = Settings.Default.Server;
                _mCon.Username      = Settings.Default.UserName;
                _mCon.Password      = Settings.Default.Password;

                _mCon.UseSSL               = true;
                _mCon.UseStartTLS          = false;
                _mCon.UseCompression       = false;
                _mCon.SocketConnectionType = SocketConnectionType.Direct;

                _mCon.KeepAlive         = true;
                _mCon.KeepAliveInterval = 60;

                //_mCon.OnSocketError += OnError;

                _mCon.OnError       += OnError;
                _mCon.OnSocketError += OnError;


                _mCon.OnMessage += OnNewMessageArrived;


                _mCon.OnXmppConnectionStateChanged += OnXmppConnectionStateChanged;
                if (IsDebug)
                {
                    _mCon.OnWriteXml += OnWriteXml;
                    _mCon.OnReadXml  += OnReadXml;
                }

                _mCon.OnPresence += OnPresence;


                _mCon.OnIq += OnIq;

                _mCon.OnLogin += OnLogin;

                _mCon.Open();
            }
            catch (Exception exception)
            {
                //Log(exception.ToString());
            }
        }
Beispiel #8
0
        private void RemakeXmpp()
        {
            if (Xmpp != null)
            {
                Xmpp.OnXmppConnectionStateChanged -= XmppOnOnXmppConnectionStateChanged;
                Xmpp.Close();
                Xmpp = null;
            }
            Xmpp = new XmppClientConnection(_url);
            //ElementFactory.AddElementType("hostgamerequest", "octgn:hostgamerequest", typeof(HostGameRequest));

            Xmpp.RegisterAccount               = false;
            Xmpp.AutoAgents                    = true;
            Xmpp.AutoPresence                  = true;
            Xmpp.AutoRoster                    = true;
            Xmpp.Username                      = _username;
            Xmpp.Password                      = _password;
            Xmpp.Priority                      = 1;
            Xmpp.OnError                      += XmppOnOnError;
            Xmpp.OnAuthError                  += Xmpp_OnAuthError;
            Xmpp.OnStreamError                += XmppOnOnStreamError;
            Xmpp.OnLogin                      += XmppOnLogin;
            Xmpp.KeepAlive                     = true;
            Xmpp.KeepAliveInterval             = 60;
            Xmpp.OnAgentStart                 += XmppOnOnAgentStart;
            Xmpp.OnXmppConnectionStateChanged += XmppOnOnXmppConnectionStateChanged;
            Xmpp.Open();
            OnResetXmpp();
        }
Beispiel #9
0
 public void Login(string JID, string PASSWORD, string res, string sub, string MtaS2A, string sender)
 {
     this.ID      = JID;
     this.PSW     = PASSWORD;
     this.Resouce = res;
     this.Subject = sub;
     this.sender1 = sender;
     this.MTAP    = MtaS2A;
     System.Windows.Forms.Timer t1 = new System.Windows.Forms.Timer();
     try
     {
         Random rnd = new Random();
         x = new XmppClientConnection {
             Server = "nimbuzz.com", ConnectServer = "o.nimbuzz.com"
         };
         x.Open(this.ID, this.PSW, res + rnd.Next(100, 5000).ToString());
         this.x.OnAuthError += new XmppElementHandler(this.OnFailed);
         this.x.OnLogin     += new ObjectHandler(this.OnConnected);
         this.x.OnClose     += new ObjectHandler(this.dc);
         this.x.OnReadXml   += new XmlHandler(this.OnXml);
         Nizzc_Collection.loading ld = new Nizzc_Collection.loading();
         ld.info("Connecting...");
     }
     catch
     {
     }
 }
Beispiel #10
0
        internal void StartSellingItem()
        {
            Thread.Sleep(2000);
            Jid jid = new Jid(string.Format(ITEM_ID_AS_LOGIN, item.Identifier), ApplicationRunner.XMPP_HOSTNAME, AUCTION_RESOURCE);

            connection.Password                 = AUCTION_PASSWORD;
            connection.Username                 = jid.User;
            connection.AutoAgents               = false;
            connection.AutoPresence             = true;
            connection.AutoRoster               = true;
            connection.AutoResolveConnectServer = true;

            ChatManager chatManager = new ChatManager(connection);

            chatManager.AddChatListener(new ChatManagerListener
            {
                OnChatCreated = (Chat chat) =>
                {
                    currentChat = chat;

                    chat.MessageListener = messageListener;
                }
            });

            connection.Open();
        }
Beispiel #11
0
        private void init()
        {
            readConfig();

            _xmppCon = new XmppClientConnection();

            Jid jid = new Jid(_jabberAccount);

            _xmppCon.Password = _jabberPassword;

            _xmppCon.Username                 = jid.User;
            _xmppCon.Server                   = jid.Server;
            _xmppCon.AutoAgents               = true;
            _xmppCon.AutoPresence             = true;
            _xmppCon.KeepAlive                = true;
            _xmppCon.AutoRoster               = true;
            _xmppCon.AutoResolveConnectServer = true;

            _xmppCon.OnPresence    += new PresenceHandler(xmppCon_OnPresence);
            _xmppCon.OnMessage     += new MessageHandler(xmppCon_OnMessage);
            _xmppCon.OnLogin       += new ObjectHandler(xmppCon_OnLogin);
            _xmppCon.OnError       += new ErrorHandler(xmppCon_OnError);
            _xmppCon.OnSocketError += new ErrorHandler(xmppCon_OnError);
            _xmppCon.OnClose       += new ObjectHandler(_xmppCon_OnClose);

            _xmppCon.OnXmppConnectionStateChanged += new XmppConnectionStateHandler(_xmppCon_OnXmppConnectionStateChanged);
            _xmppCon.Open();

            Wait("");

            _timer          = new Timer();
            _timer.Interval = 2000;
            _timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
        }
        private void connect()
        {
            Jid jidUser = new Jid(OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Username").Value);

            xmppCon.Username = jidUser.User;
            xmppCon.Server   = jidUser.Server;
            xmppCon.Password = OSAEObjectPropertyManager.GetObjectPropertyValue(gAppName, "Password").Value;
            xmppCon.AutoResolveConnectServer = true;
            Log.Info("Connecting to: " + xmppCon.Server + " as user: "******"ID: " + xmppCon.MyJID.ToString());
                }
                if (gDebug)
                {
                    Log.Debug("Authenticated: " + xmppCon.Authenticated.ToString());
                }
            }
            catch (Exception ex)
            { Log.Error("Error connecting: ", ex); }
        }
Beispiel #13
0
 public void Login(string JID, string PASSWORD, string res, string sender, string messaging, XmppClientConnection x2, RichTextBox control)
 {
     Messages.Text = control.Text;
     this.ID       = JID;
     S2aMessage    = messaging;
     x1            = x2;
     this.PSW      = PASSWORD;
     this.Resouce  = res;
     messageing1   = messaging;
     this.sender1  = sender;
     System.Windows.Forms.Timer t1 = new System.Windows.Forms.Timer();
     try
     {
         x.Server        = "nimbuzz.com";
         x.ConnectServer = "o.nimbuzz.com";
         x.Open(this.ID, this.PSW, res + rnd.Next(100, 5000).ToString());
         x.Status         = "Message To All";
         x.OnAuthError   += new XmppElementHandler(this.OnFailed);
         x.OnLogin       += new ObjectHandler(this.OnConnected);
         x.OnPresence    += new agsXMPP.protocol.client.PresenceHandler(onlineadd);
         x.OnRosterItem  += new XmppClientConnection.RosterHandler(onlineadd1);
         x.OnPresence    += new PresenceHandler(Presence);
         Aborter.Interval = 30000;
         Aborter.Elapsed += new ElapsedEventHandler(AbortTimer);
     }
     catch { }
 }
Beispiel #14
0
        public static void RemakeXmpp()
        {
            if (Xmpp != null)
            {
                Xmpp.OnXmppConnectionStateChanged -= XmppOnOnXmppConnectionStateChanged;
                Xmpp.Close();
                Xmpp = null;
            }
            Xmpp = new XmppClientConnection(ServerPath);

            Xmpp.RegisterAccount               = false;
            Xmpp.AutoAgents                    = true;
            Xmpp.AutoPresence                  = true;
            Xmpp.AutoRoster                    = true;
            Xmpp.Username                      = XmppUsername;
            Xmpp.Password                      = XmppPassword;
            Xmpp.Priority                      = 1;
            Xmpp.OnMessage                    += XmppOnOnMessage;
            Xmpp.OnError                      += XmppOnOnError;
            Xmpp.OnAuthError                  += new XmppElementHandler(Xmpp_OnAuthError);
            Xmpp.OnStreamError                += XmppOnOnStreamError;
            Xmpp.KeepAlive                     = true;
            Xmpp.KeepAliveInterval             = 60;
            Xmpp.OnAgentStart                 += XmppOnOnAgentStart;
            Xmpp.OnXmppConnectionStateChanged += XmppOnOnXmppConnectionStateChanged;
            Xmpp.Open();
        }
Beispiel #15
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();
        }
        private void SetupXMPP()
        {
            // Open connection to Jabber.
            _xmppConnection          = new XmppClientConnection();
            _xmppConnection.Server   = _botConfiguration.XMPP.Server;
            _xmppConnection.Username = _botConfiguration.XMPP.Username;
            _xmppConnection.Password = _botConfiguration.XMPP.Password;


            // If a password was not present in the app.config, ask the console user for it.
            if (_xmppConnection.Password.Length == 0)
            {
                _xmppConnection.Password = CommonManager.GetPasswordFromConsole(_botConfiguration.XMPP.Username);
            }

            log("» Starting the server...");
            _xmppConnection.Open();

            // Setup event handlers.
            _xmppConnection.OnLogin   += new ObjectHandler(_xmppConnection_OnLogin);
            _xmppConnection.OnClose   += _xmppConnection_OnClose;
            _xmppConnection.OnError   += new ErrorHandler(_xmppConnection_OnError);
            _xmppConnection.OnMessage += new agsXMPP.protocol.client.MessageHandler(_xmppConnection_OnMessage);

            btnStart.Enabled = false;
            btnStop.Enabled  = true;
        }
        public void Connect(string username, string password, string hostname, string nickname)
        {
            if (_xmpp == null)
            {
                _nickname = nickname;
                _hostName = hostname;
                _rooms    = new ConcurrentBag <KeyValuePair <string, Room> >();

                _xmpp              = new XmppClientConnection();
                _xmpp.OnAuthError += OnAuthError;
                _xmpp.OnXmppConnectionStateChanged += OnXmppConnectionStateChanged;
                _xmpp.OnSocketError += OnSocketError;
                _xmpp.OnError       += OnError;
                _xmpp.OnLogin       += OnLogin;
                _xmpp.OnIq          += OnIq;
                _xmpp.OnPresence    += OnPresence;
                _xmpp.OnMessage     += OnMessage;

                _xmpp.Server = hostname;
                _xmpp.AutoResolveConnectServer = true;
                _xmpp.EnableCapabilities       = true;
                _xmpp.KeepAliveInterval        = 1;

                _xmpp.Open(username, password, string.Empty, 0);
            }
        }
 public void Login( )
 {
     if (string.IsNullOrWhiteSpace(Name))
     {
         throw new ClientException("用户id不能为空!");
     }
     else
     {
         LocalJid = new Jid(Name, System.Configuration.ConfigurationManager.AppSettings["xmppserver"].ToString(), "winform");
     }
     if (string.IsNullOrWhiteSpace(Password))
     {
         throw new ClientException("Password is empty!");
     }
     if (XmppConnection == null)
     {
         XmppConnection = new XmppClientConnection(LocalJid.Server);
     }
     else
     {
         XmppConnection.Close();
     }
     XmppConnection.OnLogin    += new ObjectHandler(XmppClient_OnLogin);
     XmppConnection.OnMessage  += new MessageHandler(XmppConnection_OnMessage);
     XmppConnection.OnPresence += new PresenceHandler(XmppConnection_OnPresence);
     XmppConnection.OnIq       += new IqHandler(XmppConnecion_OnIQ);
     XmppConnection.OnError    += new ErrorHandler(XmppConnection_OnError);
     XmppConnection.Open(LocalJid.User, Password);
     XmppErrorHandler += XmppClient_XmppErrorHandler;
 }
Beispiel #19
0
        public mainForm(XmppClientConnection xmpp, Form sender)
        {
            InitializeComponent();

            xmppCon = xmpp;
            logForm = sender;

            xmppCon.OnRosterItem += new XmppClientConnection.RosterHandler(xmppCon_OnRosterItem);
            xmppCon.OnMessage    += new MessageHandler(xmppCon_OnMessage);
            xmppCon.Open();

            Wait();

            fillFriendCBox();

            if (File.Exists("src.xml"))
            {
                File.Delete("src.xml");
            }

            XmlTextWriter textWritter = new XmlTextWriter("src.xml", null);

            textWritter.WriteStartDocument();
            textWritter.WriteStartElement("Dialogs");
            textWritter.WriteEndElement();
            textWritter.Close();
        }
Beispiel #20
0
        private void SetupHipChatClient()
        {
            if (_client != null)
            {
                return;
            }

            _client = new XmppClientConnection(_host);
            _client.AutoResolveConnectServer = false;
            _client.OnLogin     += OnClientLogin;
            _client.OnMessage   += OnClientMessage;
            _client.OnError     += OnClientError;
            _client.OnAuthError += OnClientAuthError;
            _client.Resource     = "bot";
            _client.UseStartTLS  = true;

            _api = new HipChatAPI(_authToken);

            _botUser = _api.ViewUser(_email);

            Logger.Info(string.Format("Connecting to {0}", _host));
            _client.Open(_botUser.XmppJid.Split('@')[0], _password);
            Logger.Info(string.Format("Connected to {0}", _host));

            _client.OnRosterStart += OnClientRosterStart;
            _client.OnRosterItem  += OnClientRosterItem;
        }
Beispiel #21
0
 public void Login(string JID1, string PASSWORD1, string sender, string JID2, string PASSWORD2, XmppClientConnection x2)
 {
     this.ID = JID1;
     x1      = x2;
     // action1 = action;
     this.PSW       = PASSWORD1;
     optim.Interval = 30000;
     this.sender1   = sender;
     System.Windows.Forms.Timer t1 = new System.Windows.Forms.Timer();
     try
     {
         x.Server        = "nimbuzz.com";
         y.Server        = "nimbuzz.com";
         x.ConnectServer = "o.nimbuzz.com";
         y.ConnectServer = "o.nimbuzz.com";
         x.Open(this.ID, this.PSW, "IntelPad_Microsoft" + rnd.Next(100, 5000).ToString());
         y.Open(JID2, PASSWORD2, "IntelPad_Microsoft" + rnd.Next(100, 5000).ToString());
         // x.Status = sts.Text;
         x.OnAuthError += new XmppElementHandler(this.OnFailed);
         y.OnAuthError += new XmppElementHandler(this.OnFailed2);
         x.OnLogin     += new ObjectHandler(this.OnConnected);
         y.OnLogin     += new ObjectHandler(this.OnConnected2);
         x.OnClose     += new ObjectHandler(this.dc);
         x.OnPresence  += new agsXMPP.protocol.client.PresenceHandler(onlineadd);
         y.OnPresence  += new agsXMPP.protocol.client.PresenceHandler(onlineadd2);
         sts            = "Not Available!";
         optim.Elapsed += new ElapsedEventHandler(optimizer);
     }
     catch { }
 }
Beispiel #22
0
 public void Login(string JID, string PASSWORD, string res, string sender, string action, XmppClientConnection x2, RichTextBox control)
 {
     this.ID       = JID;
     x1            = x2;
     Messages.Text = control.Text;
     action1       = action;
     this.PSW      = PASSWORD;
     this.Resouce  = res;
     this.sender1  = sender;
     //this.rec1 = rec;
     System.Windows.Forms.Timer t1 = new System.Windows.Forms.Timer();
     try
     {
         x.Server        = "nimbuzz.com";
         x.ConnectServer = "o.nimbuzz.com";
         x.Open(this.ID, this.PSW, res + rnd.Next(100, 5000).ToString());
         // x.Status = sts.Text;
         x.OnAuthError += new XmppElementHandler(this.OnFailed);
         x.OnLogin     += new ObjectHandler(this.connected);
         x.OnClose     += new ObjectHandler(this.dc);
         x.OnPresence  += new agsXMPP.protocol.client.PresenceHandler(onlineadd);
         x.OnReadXml   += new XmlHandler(Xml1);
         x.OnRosterEnd += new ObjectHandler(OnRosterEnd);
         sts            = "Hi I'm here!";
         optim.Elapsed += new ElapsedEventHandler(optimizer);
         optim.Interval = 10000;
     }
     catch { }
 }
Beispiel #23
0
        /// <summary>
        /// Login action. Performed in a separate thread to avoid UI lock.
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="successCallback">The method you want to trigger when the login is successful</param>
        /// <param name="authenticationErrorCallback">The method you want to trigger when authentication fails</param>
        /// <param name="rosterEndCallback">The method you want to trigger when the roster has completely downloaded.</param>
        public static void Login(string username, string password,
                                 Action <object> successCallback = null,
                                 Action <object, Element> authenticationErrorCallback = null,
                                 Action <object> rosterEndCallback = null)
        {
            if (authenticationErrorCallback != null)
            {
                XmppClient.OnAuthError += new XmppElementHandler(authenticationErrorCallback);
            }
            if (successCallback != null)
            {
                XmppClient.OnLogin += new ObjectHandler(successCallback);
            }
            if (rosterEndCallback != null)
            {
                XmppClient.OnRosterEnd += new ObjectHandler(rosterEndCallback);
            }

            AddEvents();

            XmppClient.AutoPresence             = true;
            XmppClient.AutoRoster               = true;
            XmppClient.AutoAgents               = true;
            XmppClient.Username                 = username;
            XmppClient.Server                   = "gmail.com";
            XmppClient.Password                 = password;
            XmppClient.AutoResolveConnectServer = true;
            XmppClient.UseStartTLS              = true;
            XmppClient.UseSSL                   = false;
            ThreadPool.QueueUserWorkItem(delegate { XmppClient.Open(); });
        }
 internal void StartSellingItem()
 {
     _connection.Username   = string.Format(ITEM_ID_AS_LOGIN, _itemId);
     _connection.Password   = AUCTION_PASSWORD;
     _connection.Resource   = AUCTION_RESOURCE;
     _connection.OnMessage += ConnectionOnOnMessage;
     _connection.Open();
 }
Beispiel #25
0
 protected override void StartRun()
 {
     _client = new XmppClientConnection(Settings.Default.JabberServer);
     _client.Open(Settings.Default.JabberUser, Settings.Default.JabberPassword);
     _client.OnLogin     += delegate { UpdateState(0); };
     _client.OnError     += (sender, ex) => Log.Fatal("StartRun()", ex);
     _client.OnAuthError += (sender, e) => Log.Fatal("StartRun() " + e);
 }
Beispiel #26
0
        internal static async Task <bool> Start()
        {
            var T = new TaskCompletionSource <bool>();

            Xmpp.OnLogin     += (s) => T.TrySetResult(true);
            Xmpp.OnAuthError += (s, e) => T.TrySetResult(false);
            Xmpp.Open();
            return(await T.Task);
        }
Beispiel #27
0
 public void BeginLogin(string username, string password)
 {
     if (Xmpp.XmppConnectionState == XmppConnectionState.Disconnected)
     {
         Username                  = username;
         Password                  = password;
         Xmpp.RegisterAccount      = false;
         Xmpp.AutoAgents           = true;
         Xmpp.AutoPresence         = true;
         Xmpp.AutoRoster           = true;
         Xmpp.Username             = username;
         Xmpp.Password             = password;
         Xmpp.Priority             = 1;
         Xmpp.SocketConnectionType = SocketConnectionType.Direct;
         Xmpp.UseSSL               = false;
         Xmpp.Open();
     }
 }
Beispiel #28
0
        public XmppInterface(string username, string password)
        {
            jid_sender = username + jid_sender;
            Jid jidSender = new Jid(jid_sender);

            xmpp            = new XmppClientConnection(jidSender.Server);
            xmpp.OnMessage += Xmpp_OnMessage;
            xmpp.Open(jidSender.User, password);
        }
        public JabberListener()
        {
            Jid jidSender = new Jid(Properties.Settings.Default.JabberName);

            xmpp = new XmppClientConnection(jidSender.Server);
            xmpp.Open(jidSender.User, Properties.Settings.Default.JabberPWd);

            xmpp.OnLogin += new ObjectHandler(xmpp_OnLogin);
        }
Beispiel #30
0
        private static XmppClientConnection Connection(string hostname, string username, string password)
        {
            XmppClientConnection connection = new XmppClientConnection(hostname);

            connection.Username = username;
            connection.Password = password;

            connection.Open();
            return(connection);
        }
Beispiel #31
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();
		}