Open() public method

This method open the connections to the xmpp server and authenticates you to ther server. This method is async, don't assume you are already connected when it returns. You have to wait for the OnLogin Event
public Open ( ) : void
return void
Exemplo n.º 1
0
        public RiotChat(string user, string pass)
        {
            xmpp = new XmppClientConnection();
            roster = new List<Presence>();

            xmpp.Username = user;
            xmpp.Password = "******" + pass;

            xmpp.Server = "pvp.net";
            xmpp.ConnectServer = "chat.na1.lol.riotgames.com";
            xmpp.Port = 5223;
            xmpp.AutoResolveConnectServer = false;
            xmpp.UseCompression = false;
            xmpp.UseStartTLS = false;
            xmpp.UseSSL = true;

            xmpp.OnAuthError += new XmppElementHandler(xmpp_OnEleError);
            xmpp.OnError += new ErrorHandler(xmpp_OnError);
            xmpp.OnStreamError += new XmppElementHandler(xmpp_OnEleError);
            xmpp.OnSocketError += new ErrorHandler(xmpp_OnError);

            xmpp.OnLogin += new ObjectHandler(xmpp_OnLogin);
            xmpp.OnPresence += new PresenceHandler(xmpp_OnPresence);
            xmpp.OnReadXml += new XmlHandler(xmpp_OnReadXML);
            xmpp.OnWriteXml += new XmlHandler(xmpp_OnWriteXML);
            xmpp.OnMessage += new MessageHandler(xmpp_OnMessage);

            xmpp.Open();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 断线重登陆
        /// </summary>
        private void Login()
        {
            string strUserName      = this._UserName;
            string strPassword      = this._strPassword;
            string strServer        = this._strServer;
            string strServerName    = this._strServerName;
            string strMonitorServer = this._strMonitorServer;

            objXmpp = new agsXMPP.XmppClientConnection();

            if (strUserName.Split('@').Length == 1)
            {
                strUserName = strUserName + "@" + strServer;
            }

            agsXMPP.Jid jid = new agsXMPP.Jid(strUserName);
            objXmpp.Password = strPassword;
            objXmpp.Username = jid.User;
            objXmpp.Server   = jid.Server;
            objXmpp.AutoResolveConnectServer = true;

            objXmpp.OnLogin      += new ObjectHandler(objXmpp_OnLogin);                              //登录
            objXmpp.OnAuthError  += new XmppElementHandler(objXmpp_OnAuthError);                     //验证出错
            objXmpp.OnMessage    += new agsXMPP.protocol.client.MessageHandler(objXmpp_OnMessage);   //消息处理
            objXmpp.OnPresence   += new agsXMPP.protocol.client.PresenceHandler(objXmpp_OnPresence); //状态处理
            objXmpp.OnRosterItem += new XmppClientConnection.RosterHandler(objXmpp_OnRosterItem);    //加载好友列表
            objXmpp.OnRosterEnd  += new ObjectHandler(objXmpp_OnRosterEnd);                          //好友列表加载完成
            objXmpp.OnXmppConnectionStateChanged += new XmppConnectionStateHandler(objXmpp_OnXmppConnectionStateChanged);
            objXmpp.OnSocketError += new ErrorHandler(objXmpp_OnSocketError);
            objXmpp.OnError       += new ErrorHandler(objXmpp_OnError);
            objXmpp.Resource       = "Maitiam IM";//客户端版本信息
            objXmpp.ClientVersion  = "1.0";
            objXmpp.Status         = strServerName;
            objXmpp.Open();
        }
Exemplo n.º 3
0
        public event MessageHandler Messages;//消息事件

        public XMPPClass(string strUserName, string strPassword, string strServer)
        {
            objXmpp = new agsXMPP.XmppClientConnection();

            if (strUserName.Split('@').Length == 1)
            {
                strUserName = strUserName + "@" + strServer;
            }

            agsXMPP.Jid jid = new agsXMPP.Jid(strUserName);
            objXmpp.Password = strPassword;
            objXmpp.Username = jid.User;
            objXmpp.Server   = jid.Server;
            objXmpp.AutoResolveConnectServer = true;

            try
            {
                objXmpp.OnLogin      += new ObjectHandler(objXmpp_OnLogin);                              //登录
                objXmpp.OnAuthError  += new XmppElementHandler(objXmpp_OnAuthError);                     //验证出错
                objXmpp.OnMessage    += new agsXMPP.protocol.client.MessageHandler(objXmpp_OnMessage);   //消息处理
                objXmpp.OnPresence   += new agsXMPP.protocol.client.PresenceHandler(objXmpp_OnPresence); //状态处理
                objXmpp.OnRosterItem += new XmppClientConnection.RosterHandler(objXmpp_OnRosterItem);    //加载好友列表

                objXmpp.Resource = "Maitiam IM";                                                         //客户端版本信息
                objXmpp.Open();
            }
            catch (System.Exception ex)
            {
                LogError(ex.ToString());
            }
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
        public override Task Run()
        {
            _xmppConnection = new XmppClientConnection
            {
                Server = _host,
                ConnectServer = _connectHost,
                AutoResolveConnectServer = true,
                Username = _username,
                Password = _password,
            };

            _xmppConnection.OnLogin += OnLogin;
            _xmppConnection.OnError += OnError;
            _xmppConnection.OnMessage += OnMessage;
            _xmppConnection.OnPresence += XmppConnectionOnOnPresence;
            _xmppConnection.OnRosterItem += OnClientRosterItem;

            

            CancelPreviousLogin();

            _loginTcs = new TaskCompletionSource<bool>();

            _xmppConnection.Open();

            //return _loginTcs == null ? Task.FromResult(false) :  _loginTcs.Task;
            return Task.FromResult(false);
        }
        public void Conectar(string user, string password)
        {
            XmppClientConnection xmpp = new XmppClientConnection("pvp.net");
            xmpp.UseSSL = true;
            xmpp.Port = 5223;
            xmpp.Resource = "xiff";
            xmpp.AutoResolveConnectServer = false;
            xmpp.ConnectServer = "chat.euw1.lol.riotgames.com";
            //Presence p = new Presence(ShowType.chat, "Online");
            //p.Type = PresenceType.available;
            //xmpp.Send(p);
            xmpp.OnRosterItem += new XmppClientConnection.RosterHandler( xmpp_OnRosterItem);
            xmpp.OnPresence += new PresenceHandler(xmpp_OnPresence);
            xmpp.Open(user, "AIR_" + password);

            //xmpp.OnLogin += delegate (object o) { MessageBox.Show("Logged in as " + xmpp.Username); };
            System.Threading.Thread.Sleep(2000);
            foreach (string nome in Contactos_Todos)
                    {

                Offline_Friends.Items.Add(nome);
                       
                    }
            foreach (string nome in Contactos)
            {

                Online_Friends.Items.Add(nome);

            }
            button.Background = Brushes.Green;
            button.IsEnabled = false;
            button.Content = "CONECTED!";
            
        }
        public void Login(string username, string password)
        {
            if (!LoggedIn)
            {
                try
                {
                    _xmppClient = new XmppClientConnection("chat.facebook.com", 5222);
                    _xmppClient.OnXmppConnectionStateChanged += (sender, state) =>
                    {
                        if (OnConnectionStateChanged != null) OnConnectionStateChanged(state.ToString());
                    };
                    _xmppClient.UseStartTLS = true;
                    _xmppClient.OnPresence += UpdateContactList;
                    _xmppClient.OnLogin += OnLogin;
                    _xmppClient.OnAuthError += (sender, element) =>
                    {
                        if (OnAuthError != null) OnAuthError(element.ToString());
                    };

                   _xmppClient.Open(username, password);
                }
                catch
                {
                    if (OnLoginResult != null)
                        OnLoginResult(false);
                }
            }
        }
Exemplo n.º 8
0
        public void Start()
        {
            AppDomain.CurrentDomain.AssemblyResolve += (o, args) =>
            {
                var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
                return loadedAssemblies.FirstOrDefault(asm => asm.FullName == args.Name);
            };

            string pluginsDirectory = Environment.CurrentDirectory + "\\plugins\\";
            if (!Directory.Exists(pluginsDirectory))
            {
                Directory.CreateDirectory(pluginsDirectory);
            }

            _catalog = new DirectoryCatalog(Environment.CurrentDirectory + "\\plugins\\");
            _catalog.Changed += new EventHandler<ComposablePartCatalogChangeEventArgs>(_catalog_Changed);
            LoadPlugins();

            _client = new XmppClientConnection(ConfigurationManager.AppSettings["Server"]);

            //_client.ConnectServer = "talk.google.com"; //necessary if connecting to Google Talk
            _client.AutoResolveConnectServer = false;

            _client.OnLogin += new ObjectHandler(xmpp_OnLogin);
            _client.OnMessage += new MessageHandler(xmpp_OnMessage);
            _client.OnError += new ErrorHandler(_client_OnError);

            Console.WriteLine("Connecting...");
            _client.Resource = ConfigurationManager.AppSettings["Resource"];
            _client.Open(ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Password"]);
            Console.WriteLine("Connected.");

            _client.OnRosterStart += new ObjectHandler(_client_OnRosterStart);
            _client.OnRosterItem += new XmppClientConnection.RosterHandler(_client_OnRosterItem);
        }
        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);
        }
Exemplo n.º 10
0
 protected override void StartRun()
 {
     _client = new XmppClientConnection(Settings.Instance.JabberServer);
     _client.Open(Settings.Instance.JabberUser, Settings.Instance.JabberPassword);
     _client.OnLogin += delegate { UpdateState(0); };
     _client.OnError += (sender, ex) => Log.Fatal("StartRun()", ex);
     _client.OnAuthError += (sender, e) => Log.Fatal("StartRun() " + e);
 }
Exemplo n.º 11
0
 public void XmppSendTest()
 {
     var xmpp = new XmppClientConnection(domain);
     xmpp.ConnectServer = connectserver;
     xmpp.Open(username, password);
     xmpp.OnError += new ErrorHandler(delegate { logerror(); });
     xmpp.OnLogin += delegate(object o) { xmpp.Send(new Message(new Jid(recipient), MessageType.chat, "james")); };
     while (!xmpp.Authenticated)
         System.Threading.Thread.Sleep(500);
     System.Threading.Thread.Sleep(1000);
     xmpp.Send(new Message(new Jid(recipient), MessageType.chat, "james"));
     xmpp.Close();
 }
Exemplo n.º 12
0
 static void Main(string[] args)
 {
     Console.ReadLine();
     XmppClientConnection xmppCon = new XmppClientConnection();
     xmppCon.Username = "******";
     xmppCon.Password = "******";
     xmppCon.Server = "talk.google.com";
     xmppCon.Port = 443;
     xmppCon.UseStartTLS = true;
     xmppCon.AutoResolveConnectServer = true;
     xmppCon.Open();
     Console.WriteLine("Bye");
 }
Exemplo n.º 13
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;
        }
Exemplo n.º 14
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     xmppCon = new XmppClientConnection();
     xmppCon.OnLogin += new ObjectHandler(xmppCon_OnLogin);
     xmppCon.OnAuthError += new XmppElementHandler(xmppCon_OnAuthError);
     xmppCon.OnError += new ErrorHandler(xmppCon_OnError);
     xmppCon.Username = "******";
     xmppCon.Password = "******";
     xmppCon.Server = "talk.google.com";
     xmppCon.Port = 443;
     //xmppCon.UseStartTLS = true;
     xmppCon.KeepAlive = true;
     xmppCon.AutoResolveConnectServer = true;
     xmppCon.Open();
 }
Exemplo n.º 15
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();
        }
Exemplo n.º 16
0
        public void Start()
        {
            _client = new XmppClientConnection(_robot.Settings.Get("HipChatServer"))
            {
                AutoResolveConnectServer = false
            };

            _client.OnLogin += OnLogin;
            _client.OnMessage += OnMessage;
            _client.OnRosterStart += OnRosterStart;
            _client.OnRosterItem += OnRosterItem;

            _robot.Logger.WriteLine("Connecting...");
            _client.Resource = _robot.Settings.Get("HipChatResource");
            _client.Open(_robot.Settings.Get("HipChatUser"), _robot.Settings.Get("HipChatPassword"));
            _robot.Logger.WriteLine("Connected.");
        }
Exemplo n.º 17
0
 public LOTROGateway(string cserver, string server, string username, string password, string expectedUser, string confirmMsg, bool tls)
 {
     connection = new XmppClientConnection(server);
     connection.ConnectServer = cserver;
     connection.UseStartTLS = tls;
     connection.OnMessage += new XmppClientConnection.MessageHandler(connection_OnMessage);
     connection.OnLogin += new ObjectHandler(connection_OnLogin);
     connection.OnError += new ErrorHandler(connection_OnError);
     connection.OnClose += new ObjectHandler(connection_OnClose);
     connection.OnPresence += new XmppClientConnection.PresenceHandler(connection_OnPresence);
     connection.OnSocketError += new ErrorHandler(connection_OnSocketError);
     this.username = username;
     this.password = password;
     connection.KeepAlive = true;
     connection.Open(username, password);
     this.expectedUser = expectedUser;
     this.confirmMsg = confirmMsg;
 }
Exemplo n.º 18
0
        /// <summary>
        /// 登录CTALK
        /// </summary>
        /// <param name="strUserName"></param>
        /// <param name="strPassword"></param>
        public void Login(string strUserName, string strPassword)
        {
            objXmpp = new agsXMPP.XmppClientConnection();

            if (strUserName.Split('@').Length == 1)
            {
                strUserName = strUserName + "@ishow.xba.com.cn";
            }

            agsXMPP.Jid jid = new agsXMPP.Jid(strUserName);
            objXmpp.Password = strPassword;
            objXmpp.Username = jid.User;
            objXmpp.Server   = jid.Server;
            objXmpp.AutoResolveConnectServer = true;

            try
            {
                objXmpp.OnLogin           += new agsXMPP.ObjectHandler(objXmpp_OnLogin);                    //登录
                objXmpp.OnAuthError       += new agsXMPP.XmppElementHandler(objXmpp_OnAuthError);           //验证出错
                objXmpp.OnMessage         += new agsXMPP.protocol.client.MessageHandler(objXmpp_OnMessage); //接收消息
                objXmpp.OnPresence        += new PresenceHandler(objXmpp_OnPresence);                       //状态处理
                objXmpp.OnRosterItem      += new XmppClientConnection.RosterHandler(objXmpp_OnRosterItem);  //加载好友列表
                objXmpp.OnReadSocketData  += new agsXMPP.net.BaseSocket.OnSocketDataHandler(objXmpp_OnReadSocketData);
                objXmpp.OnWriteSocketData += new agsXMPP.net.BaseSocket.OnSocketDataHandler(objXmpp_OnWriteSocketData);
                objXmpp.OnRosterEnd       += new ObjectHandler(objXmpp_OnRosterEnd);
                objXmpp.OnIq          += new IqHandler(objXmpp_OnIq);
                objXmpp.OnSocketError += new ErrorHandler(objXmpp_OnSocketError);
                objXmpp.OnStreamError += new XmppElementHandler(objXmpp_OnStreamError);
                objXmpp.OnXmppConnectionStateChanged += new XmppConnectionStateHandler(objXmpp_OnXmppConnectionStateChanged);
                objXmpp.Resource = "Maitiam IM";//客户端版本信息
                objXmpp.Open();

                G_Status("Login", "【正在登陆】");
            }
            catch (System.Exception ex)
            {
                G_Status("Error", ex.ToString());
            }
        }
Exemplo n.º 19
0
 /// <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>
 private HarmonyClient(string host, string token, int port = 5222)
 {
     Token = token;
     _xmpp = new XmppClientConnection(host, port)
     {
         UseStartTLS = false,
         UseSSL = false,
         UseCompression = false,
         AutoResolveConnectServer = false,
         AutoAgents = false,
         AutoPresence = true,
         AutoRoster = true
     };
     // 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;
     // Open the connection, do the login
     _xmpp.Open($"{token}@x.com", token);
 }
Exemplo n.º 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;

            Logger.Info(string.Format("Connecting to {0}", _host));
            _client.Open(_username, _password);
            Logger.Info(string.Format("Connected to {0}", _host));

            _client.OnRosterStart += OnClientRosterStart;
            _client.OnRosterItem += OnClientRosterItem;
        }
Exemplo n.º 21
0
        /// <summary>
        /// Attempts to send a gTalk IM to the specified account.
        /// </summary>
        public void GTalk(string username, string password, string sendToUser, string message, int connectionTimeout)
        {
            try
            {
                if (connectionTimeout > GTALK_MAX_CONNECTION_TIMEOUT)
                {
                    connectionTimeout = GTALK_MAX_CONNECTION_TIMEOUT;
                }
                else if (connectionTimeout < GTALK_DEFAULT_CONNECTION_TIMEOUT)
                {
                    connectionTimeout = GTALK_DEFAULT_CONNECTION_TIMEOUT;
                }

                XmppClientConnection xmppCon = null;

                if (m_gtalkConnections.ContainsKey(username))
                {
                    xmppCon = m_gtalkConnections[username];
                    Log("Using existing gTalk connection for " + username + "@gmail.com.");
                    xmppCon.Send(new Message(new Jid(sendToUser + "@gmail.com"), MessageType.chat, message));
                }
                else
                {
                    xmppCon = new XmppClientConnection();
                    xmppCon.Password = password;
                    xmppCon.Username = username;
                    xmppCon.Server = "gmail.com";
                    xmppCon.ConnectServer = "talk.google.com";
                    xmppCon.AutoAgents = false;
                    xmppCon.AutoPresence = false;
                    xmppCon.AutoRoster = false;
                    xmppCon.AutoResolveConnectServer = true;

                    Log("Attempting to connect to gTalk for " + username + ".");

                    ManualResetEvent waitForConnect = new ManualResetEvent(false);

                    xmppCon.OnLogin += new ObjectHandler((sender) => waitForConnect.Set());
                    xmppCon.Open();

                    if (waitForConnect.WaitOne(connectionTimeout, false))
                    {
                        Log("Connected to gTalk for " + username + "@gmail.com.");
                        if (!m_gtalkConnections.ContainsKey(username))
                        {
                            m_gtalkConnections.Add(username, xmppCon);
                        }
                        xmppCon.Send(new Message(new Jid(sendToUser + "@gmail.com"), MessageType.chat, message));
                    }
                    else
                    {
                        Log("Connection to gTalk for " + username + " timed out.");
                    }
                }
                //xmppCon.Close();
            }
            catch (Exception excp)
            {
                logger.Error("Exception GTalk. " + excp.Message);
                Log("Exception GTalk. " + excp.Message);
            }
        }
Exemplo n.º 22
0
    public static void login(string username, string password)
    {
        Jid jidSender = new Jid(username);
        XmppClientConnection xmpp = new XmppClientConnection(jidSender.Server);
        xmppManager.xmpp = xmpp;

        agsXMPP.Factory.ElementFactory.AddElementType("agixml", "softsurve:agi", typeof(AgIXML));

        xmpp.Open(jidSender.User, password);
        xmpp.OnLogin += new ObjectHandler(xmpp_OnLogin);
        xmpp.OnPresence += new PresenceHandler(xmpp_OnPresence);
        xmpp.OnMessage += Xmpp_OnMessage;
    }
Exemplo n.º 23
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());
            }
        }
Exemplo n.º 24
0
        public static void RemakeXmpp()
        {
            if (Xmpp != null)
            {
                Xmpp.OnXmppConnectionStateChanged -= XmppOnOnXmppConnectionStateChanged;
                Xmpp.Close();
                Xmpp = null;
            }
            Xmpp = new XmppClientConnection(ServerPath);
            //#else
            //            Xmpp = new XmppClientConnection();
            //            Xmpp.ConnectServer = "127.0.0.1";
            //            Xmpp.AutoResolveConnectServer = false;
            //#endif

            Xmpp.RegisterAccount = false;
            Xmpp.AutoAgents = true;
            Xmpp.AutoPresence = true;
            Xmpp.AutoRoster = true;
            Xmpp.Username = XmppUsername;
            Xmpp.Password = XmppPassword;//Don't commit real password
            Xmpp.Priority = 1;
            Xmpp.OnLogin += XmppOnOnLogin;
            Xmpp.OnMessage += XmppOnOnMessage;
            Xmpp.OnIq += XmppOnOnIq;
            Xmpp.OnError += XmppOnOnError;
            Xmpp.OnAuthError += new XmppElementHandler(Xmpp_OnAuthError);
            Xmpp.OnReadXml += XmppOnOnReadXml;
            Xmpp.OnPresence += XmppOnOnPresence;
            Xmpp.OnWriteXml += XmppOnOnWriteXml;
            Xmpp.OnStreamError += XmppOnOnStreamError;
            Xmpp.KeepAlive = true;
            Xmpp.KeepAliveInterval = 60;
            Xmpp.OnAgentStart += XmppOnOnAgentStart;
            Xmpp.OnXmppConnectionStateChanged += XmppOnOnXmppConnectionStateChanged;
            _userList = new ThreadSafeList<Jid>();
            Xmpp.Open();
        }
Exemplo n.º 25
0
        public void RemakeXmpp()
        {
            if (Xmpp != null)
            {
                Xmpp.OnXmppConnectionStateChanged -= XmppOnOnXmppConnectionStateChanged;
                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();
        }
Exemplo n.º 26
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sJid">S jid.</param>
        /// <param name="sPassword">S password.</param>
        public XmppManager(AuthInfo authInfo, XmppServiceDescription xmppServiceDescription, OTRKeyRing _OTRKeyRing, OpenPGPRing _OpenPGPRing, ConversationManager _conversationManager, AddressBook _addressBook, Logger _logger)
        {
            try
            {
                m_Logger = _logger;
                m_OTRKeyRing = _OTRKeyRing;
                m_OpenPGPRing = _OpenPGPRing;
                m_AuthInfo = authInfo;
                m_OwnJid = new Jid (m_AuthInfo.m_sId);
                m_ClientConnection = new XmppClientConnection(m_OwnJid.Server);
                m_Contacts = new Dictionary<string, string> ();
                m_Logger.log(ELogLevel.LVL_INFO, "Trying to log in xmpp user", m_sModuleName);
                m_ClientConnection.Open(m_OwnJid.User, m_AuthInfo.m_sPassword);
                m_ConversationManager = _conversationManager;
                m_AddressBook = _addressBook;
                m_PresenceManager = new PresenceManager(m_AddressBook);
                m_OtrConnections = new Dictionary<string, int>();

                //register EventHandlers
                m_ClientConnection.OnLogin += new ObjectHandler(onLogin);
                m_ClientConnection.OnPresence += new PresenceHandler(OnPresence);
            }
            catch(Exception e) {
                Console.Write (e.Message);
            }

            //info: message callback is registered in onRosterItem callback
        }
Exemplo n.º 27
0
        private XmppClientConnection connect(string server, string connserver, string username, string password)
        {
            XmppClientConnection xmpp = new XmppClientConnection();
            xmpp.Server = server;//"jabberd.eu";
            xmpp.ConnectServer = connserver;// "jabberd.eu";
            xmpp.Username = username;// "khelek";
            xmpp.Password = password;//"abe2b33519";
            xmpp.Open();//"*****@*****.**";
            xmpp.OnMessage += comMessage;
            xmpp.OnLogin += onLogin;

            return xmpp;
        }
Exemplo n.º 28
0
        public frmMain()
        {
            InitializeComponent();
            treeGC.ContextMenuStrip = contextMenuGC;
            contactListPanel.BringToFront();

            // initialize Combo Status
            cboStatus.Items.AddRange(new object[] {"offline",
                                                    ShowType.away.ToString(),
                                                    ShowType.xa.ToString(),
                                                    ShowType.chat.ToString(),
                                                    ShowType.dnd.ToString(),
                                                    "online" });
            cboStatus.SelectedIndex = 0;

            // initilaize XmppConnection
            XmppCon = new XmppClientConnection();

            XmppCon.SocketConnectionType = agsXMPP.net.SocketConnectionType.Direct;

            XmppCon.OnReadXml += new XmlHandler(XmppCon_OnReadXml);
            XmppCon.OnWriteXml += new XmlHandler(XmppCon_OnWriteXml);

            XmppCon.OnRosterStart += new ObjectHandler(XmppCon_OnRosterStart);
            XmppCon.OnRosterEnd += new ObjectHandler(XmppCon_OnRosterEnd);
            XmppCon.OnRosterItem += new agsXMPP.XmppClientConnection.RosterHandler(XmppCon_OnRosterItem);

            XmppCon.OnAgentStart += new ObjectHandler(XmppCon_OnAgentStart);
            XmppCon.OnAgentEnd += new ObjectHandler(XmppCon_OnAgentEnd);
            XmppCon.OnAgentItem += new agsXMPP.XmppClientConnection.AgentHandler(XmppCon_OnAgentItem);

            XmppCon.OnLogin += new ObjectHandler(XmppCon_OnLogin);
            XmppCon.OnClose += new ObjectHandler(XmppCon_OnClose);
            XmppCon.OnError += new ErrorHandler(XmppCon_OnError);
            XmppCon.OnPresence += new PresenceHandler(XmppCon_OnPresence);
            XmppCon.OnMessage += new MessageHandler(XmppCon_OnMessage);
            XmppCon.OnIq += new IqHandler(XmppCon_OnIq);
            XmppCon.OnAuthError += new XmppElementHandler(XmppCon_OnAuthError);
            XmppCon.OnSocketError += new ErrorHandler(XmppCon_OnSocketError);
            XmppCon.OnStreamError += new XmppElementHandler(XmppCon_OnStreamError);

            XmppCon.OnReadSocketData += new agsXMPP.net.BaseSocket.OnSocketDataHandler(ClientSocket_OnReceive);
            XmppCon.OnWriteSocketData += new agsXMPP.net.BaseSocket.OnSocketDataHandler(ClientSocket_OnSend);

            XmppCon.ClientSocket.OnValidateCertificate += new System.Net.Security.RemoteCertificateValidationCallback(ClientSocket_OnValidateCertificate);

            XmppCon.OnXmppConnectionStateChanged += new XmppConnectionStateHandler(XmppCon_OnXmppConnectionStateChanged);
            XmppCon.OnSaslStart += new SaslEventHandler(XmppCon_OnSaslStart);

            discoManager = new DiscoManager(XmppCon);

            agsXMPP.Factory.ElementFactory.AddElementType("Login", null, typeof(Settings.Login));
            LoadChatServers();

            frmLogin f = new frmLogin(XmppCon);

            if (f.ShowDialog() == DialogResult.OK)
            {
                XmppCon.Open();
            }
        }
Exemplo n.º 29
0
        private XmppClientConnection connect(string server, string connserver, string username, string password)
        {
            XmppClientConnection xmpp = new XmppClientConnection();
            xmpp.Server = server;//"jabberd.eu";
            xmpp.ConnectServer = connserver;// "jabberd.eu";
            if ( server == "haupc" || server == "192.168.1.4" ) {
                xmpp.Port = 5222;
            }
            xmpp.Username = username;// "khelek";
            xmpp.Password = password;//"abe2b33519";
            //xmpp.UseSSL = true;
            xmpp.UseStartTLS = true;

            xmpp.Open();//"*****@*****.**";
            xmpp.OnMessage += onMessage;
            xmpp.OnLogin += onLogin;
            xmpp.OnPresence += onPresence;

            return xmpp;
        }
Exemplo n.º 30
0
 private void Connect(string username, string password, string panel_name)
 {
     jid = new Jid(username, server, panel_name);
     xmpp = new XmppClientConnection(jid.Server);
     try
     {
         xmpp.Open(jid.User, password);
         xmpp.OnLogin += new ObjectHandler(xmpp_OnLogin);
         xmpp.OnAuthError += new XmppElementHandler(xmpp_OnAuthError);
         xmpp.OnClose += new ObjectHandler(xmpp_OnClose);
     }
     catch (Exception)
     {
         if (ConnectionError != null)
             ConnectionError(this, EventArgs.Empty);
     }
 }
        public override bool OnLoad(Gui.MainWindow window)
        {
            Config = Configuration.Load();

            Window = window;

            var loginWindow = new LoginWindow { txtUsername = { Text = Config.Email } };
            if (!loginWindow.ShowDialog().HasValue || LoginData == null)
            {
                return false;
            }

            Config.Email = loginWindow.Username;

            if (loginWindow.chkRemember.IsChecked != null && loginWindow.chkRemember.IsChecked.Value)
            {
                Config.Save();
            }

            SelfJid = new Jid(Nickname + "@chat.hipchat.com");

            window.Title = "Chatterbox - " + GroupName;

            HipchatClient = new XmppClientConnection("chat.hipchat.com");
            HipchatClient.Open(Nickname, loginWindow.Password);
            HipchatClient.Status = "Chatterbox";
            HipchatClient.Show = ShowType.chat;
            HipchatClient.AutoResolveConnectServer = false;
            HipchatClient.OnLogin += HipchatClient_OnLogin;

            MucManager = new MucManager(HipchatClient);

            HipchatClient.OnRosterStart += sender => Users.Clear();
            HipchatClient.OnRosterItem += HipchatClient_OnRosterItem;
            HipchatClient.OnMessage += HipchatClient_OnMessage;
            HipchatClient.OnPresence += HipchatClient_OnPresence;

            Lobby = new LobbyControl();
            Lobby.OnRoomJoin += Lobby_OnRoomJoin;

            Window.SetLobbyRoom(Lobby);

            return true;
        }
Exemplo n.º 32
0
        /// <summary>
        /// Attempt to send out the results via XMPP.
        /// </summary>
        /// <param name="result"></param>
        public void Run(IIntegrationResult result)
        {
            this.result = result;

            try
            {
                // Initialise the client and login
                hasError = false;
                messagesSent = null;
                client = new XmppClientConnection();
                client.Server = server;
                client.ConnectServer = connectServer;
                client.AutoRoster = false;
                client.Resource = null;
                client.OnLogin += new ObjectHandler(xmppClient_OnLogin);
                client.OnError += new ErrorHandler(xmppClient_OnError);
                client.OnAuthError += new XmppElementHandler(client_OnAuthError);
                Log.Debug("Connecting to XMPP server: " + server);
                client.Open(userName, password);

                // Wait for the messages to be sent
                bool continueWaiting = true;
                DateTime startWait = DateTime.Now;
                while (continueWaiting)
                {
                    Thread.Sleep(100);
                    if (hasError)
                    {
                        continueWaiting = false;
                    }
                    else if (client.Authenticated)
                    {
                        if (messagesSent.HasValue)
                        {
                            TimeSpan timeWaited = (DateTime.Now - messagesSent.Value);
                            continueWaiting = (timeWaited.TotalSeconds < sendPeriod);
                        }
                    }

                    // Time-out after the specified time
                    if (continueWaiting)
                    {
                        TimeSpan timeWaited = (DateTime.Now - startWait);
                        if (timeWaited.TotalSeconds > timeOutPeriod)
                        {
                            continueWaiting = false;
                            Log.Warning("Time-out period has expired - send was not successful");
                        }
                    }
                }

                // Clean up
                client.Close();
                client = null;
            }
            catch (Exception error)
            {
                Log.Error(error);
                result.ExceptionResult = error;
                result.Status = ThoughtWorks.CruiseControl.Remote.IntegrationStatus.Exception;
            }
        }
Exemplo n.º 33
-1
        static GameBot()
        {
            //#if(DEBUG)
            Xmpp = new XmppClientConnection("skylabsonline.com");
            //#else
            //            Xmpp = new XmppClientConnection();
            //            Xmpp.ConnectServer = "127.0.0.1";
            //            Xmpp.AutoResolveConnectServer = false;
            //#endif

            Xmpp.RegisterAccount = false;
            Xmpp.AutoAgents = true;
            Xmpp.AutoPresence = true;
            Xmpp.AutoRoster = true;
            Xmpp.Username = "******";
            Xmpp.Password = "******";//Don't commit real password

            Xmpp.Priority = 1;
            Xmpp.OnLogin += XmppOnOnLogin;
            Xmpp.OnMessage += XmppOnOnMessage;
            Xmpp.OnIq += XmppOnOnIq;
            Xmpp.OnError += XmppOnOnError;
            Xmpp.OnAuthError += new XmppElementHandler(Xmpp_OnAuthError);
            Xmpp.OnReadXml += XmppOnOnReadXml;
            Xmpp.OnPresence += XmppOnOnPresence;
            Xmpp.OnWriteXml += XmppOnOnWriteXml;
            Xmpp.OnXmppConnectionStateChanged += XmppOnOnXmppConnectionStateChanged;
            _userList = new ThreadSafeList<Jid>();
            Xmpp.Open();
        }