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();
                    }

  • 相关阅读:
    Qt的.pro文件
    AI_八数码
    安装 MINGW GCC 4.4.0
    VC中应用Excel
    八数码问题_启发搜索
    【收集】【收藏】【转帖】game development resouce
    QT小记之在VS2005中使用QT
    [转文]VS2008 安装 Boost 1.43.0
    搬家到博客园了
    转 暴雪总裁总结游戏十条经验
  • 原文地址:https://www.cnblogs.com/sdikerdong/p/2404938.html
Copyright © 2011-2022 走看看