zoukankan      html  css  js  c++  java
  • relay send message to offline user communicator 2007

    用OC如何像QQ一样发送离线消息呢?今天学习了一整天,有一点结果。最简单的方法是用OC Auamation API. 下述是伪代码,只用来表示如果使用automation API实现。

    //在调用前,oc客户端要被运行起来,可能没有登录

    CommunicatorAPI.MessengerClass communicatorObj = new CommunicatorAPI.MessengerClass();

    if (communicatorObj.MyStatus != MISTATUS.MISTATUS_OFFLINE)
     {
                        //If already signed in, then set connected status to true and return.
                        connected = true;       // Set the connected status to true.
    }
    else
    {
       try
        {
                //communicatorObj.Signin();
                communicatorObj.AutoSignin(); //如果自动登录,用gpedit可以设定
        }
        catch { }
    }

        //方法一:

                    //load selected contacts into ArrayList.
                    ArrayList contactArray =  new ArrayList() ;
                    contactArray.Add(a@a.com);
                    contactArray.Add(b@a.com);

                    //dimension object array to the number of contacts selected
                    object[] sipUris = new object[contactArray.Count];
                    int currentObject = 0;

                    //iterate over contactArray and load each individual
                    //contact into object array element.
                    foreach (object contactObject in contactArray)
                    {
                        sipUris[currentObject] = contactObject;
                        currentObject ++;
                    }

                    //communicatorObj.OnIMWindowCreated += new DMessengerEvents_OnIMWindowCreatedEventHandler(communicatorObj_OnIMWindowCreated);
                    CommunicatorAPI.IMessengerAdvanced msgrAdv = communicatorObj as CommunicatorAPI.IMessengerAdvanced;
                    object obj = msgrAdv .StartConversation(CONVERSATION_TYPE.CONVERSATION_TYPE_IM,sipUris,null,"Notify","1",null) ;
                    long imWindowHandle = long.Parse(obj.ToString());
                    if (null != imWindowHandle)
                    {
                        IMessengerConversationWndAdvanced IM_Window2 = obj as IMessengerConversationWndAdvanced;
                        IM_Window2.SendText("hi");
                        IM_Window2.Show();
                    }

                //方法二

    string sipuri = "a@a.com";

                    IMessengerContactAdvanced contact = FindContact(sipuri);
                    if (contact.Status == MISTATUS.MISTATUS_OFFLINE)
                    {
                        return;
                    }
                    IMessengerConversationWndAdvanced IM_Window = communicatorObj.InstantMessage((object)sipuri) as IMessengerConversationWndAdvanced;
                    if (IM_Window != null)
                    {
                        IM_Window.SendText("hello");
                        IM_Window.Show();
                    }

  • 相关阅读:
    m-n的随机整数 包括m n
    获取url参数 hash类型
    js 数组转带空格字符串
    产生n-m的随机数组
    js 判断android、IOS
    判断是否微信浏览器
    文本左右对齐方式css
    H5微信支付流程
    H5微信授权登录流程
    H5页面 input禁止弹出键盘
  • 原文地址:https://www.cnblogs.com/sdikerdong/p/2404938.html
Copyright © 2011-2022 走看看