Пример #1
0
 /// <summary>
 /// 命令发送
 /// </summary>
 /// <param name="ToServerName"></param>
 /// <param name="strCommand"></param>
 public void SendCommand(string ToServerName, string strCommand)
 {
     agsXMPP.Jid jid = new agsXMPP.Jid(ToServerName);
     agsXMPP.protocol.client.Message sendMsg = new agsXMPP.protocol.client.Message(jid, MessageType.chat, strCommand);
     objXmpp.Send(sendMsg);
     LogTrace(ToServerName + " " + strCommand);
 }
Пример #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();
        }
Пример #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());
            }
        }
Пример #4
0
 /// <summary>
 /// Constructeur
 /// </summary>
 public Contact(agsXMPP.Jid jid, string nickname, agsXMPP.Xml.Dom.ElementList grps)
 {
     _identity = new Identity(jid);
     if (nickname != null && nickname.Trim() != string.Empty)
     {
         _identity.nickname = nickname;
     }
     if (grps != null)
     {
         foreach (agsXMPP.protocol.Base.Group g in grps)
         {
             if (!_groups.Contains(g.Name))
             {
                 _groups.Add(g.Name);
             }
         }
     }
     _status               = new Status();
     _status.type          = Enums.StatusType.Unavailable;
     _status.message       = string.Empty;
     _mood                 = new Mood();
     _mood.type            = Enums.MoodType.none;
     _mood.text            = string.Empty;
     _activity             = new Activity();
     _activity.type        = Enums.ActivityType.none;
     _activity.text        = string.Empty;
     _location             = new Location();
     _location.altitude    = 0;
     _location.latitude    = 0;
     _location.longitude   = 0;
     _location.bearing     = 0;
     _location.error       = 0;
     _location.speed       = 0;
     _location.area        = string.Empty;
     _location.building    = string.Empty;
     _location.country     = string.Empty;
     _location.datum       = string.Empty;
     _location.description = string.Empty;
     _location.floor       = string.Empty;
     _location.locality    = string.Empty;
     _location.postalcode  = string.Empty;
     _location.region      = string.Empty;
     _location.room        = string.Empty;
     _location.street      = string.Empty;
     _location.text        = string.Empty;
     _location.timestamp   = new DateTime();
     _location.uri         = string.Empty;
     _tune                 = new Tune();
     _tune.artist          = string.Empty;
     _tune.length          = 0;
     _tune.rating          = 1;
     _tune.source          = string.Empty;
     _tune.title           = string.Empty;
     _tune.track           = 0;
     _tune.uri             = string.Empty;
 }
Пример #5
0
        /// <summary>
        /// 自动发送消息
        /// </summary>
        private void AutoSendMessage()
        {
            string strContent;
            string strDebug;

            while (true)
            {
                strDebug   = lib.ReadINI("ClientConfig", "Debug");
                strContent = SIC.ShowInfo();
                agsXMPP.Jid jid = new agsXMPP.Jid(this.strMonitorServer);
                agsXMPP.protocol.client.Message autoReply = new agsXMPP.protocol.client.Message(jid, MessageType.chat, strContent);
                if (strDebug == "1")
                {
                    lib.LogTrace(strContent);
                }
                objXmpp.Send(autoReply);
                Thread.Sleep(5000);
            }
        }
Пример #6
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());
            }
        }
Пример #7
0
 /// <summary>
 /// Supprimer une ressource ou un contact avec toutes ses ressources
 /// </summary>
 /// <param name="jbid">Identifiant Jabber</param>
 public void remove(string jbid)
 {
     agsXMPP.Jid jid = new agsXMPP.Jid(jbid);
     if (jid != null) {
         if (contacts.ContainsKey(jid.Bare)) {
             if (jid.Resource != null && contacts[jid.Bare].ContainsKey(jid.Resource.Trim())) {
                 Jabber.xmpp.PresenceManager.Unsubscribe(jid);
                 Jabber.xmpp.RosterManager.RemoveRosterItem(jid);
             } else {
                 foreach (KeyValuePair<string, Contact> r in contacts[jid.Bare]) {
                     remove(r.Value.identity.jabberID.full);
                 }
                 Jabber.xmpp.PresenceManager.Unsubscribe(jid);
                 Jabber.xmpp.RosterManager.RemoveRosterItem(jid);
             }
         }
     }
 }
Пример #8
0
 /// <summary>
 /// Ajouter un contact
 /// </summary>
 /// <param name="jbid">Identifiant Jabber</param>
 public void add(string jbid)
 {
     agsXMPP.Jid jid = new agsXMPP.Jid(jbid);
     if (jid != null) {
         if (!contacts.ContainsKey(jid.Bare)) {
             Jabber.xmpp.RosterManager.AddRosterItem(new agsXMPP.Jid(jid.Bare));
             Jabber.xmpp.PresenceManager.Subscribe(new agsXMPP.Jid(jid.Bare));
         }
     }
 }