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

  • 相关阅读:
    Memcache 内存分配策略和性能(使用)状态检查
    C# 中字符串转换成日期
    Task及Mvc的异步控制器 使用探索
    MVC项目实践,在三层架构下实现SportsStore-01,EF Code First建模、DAL层等
    从壹开始前后端分离 [ Vue2.0+.NET Core2.1] 二十三║Vue实战:Vuex 其实很简单
    从壹开始前后端分离 [ Vue2.0+.NET Core2.1] 二十一║Vue实战:开发环境搭建【详细版】
    vue-router 快速入门
    Vue.js——60分钟快速入门
    五小步让VS Code支持AngularJS智能提示
    AngularJS----服务,表单,模块
  • 原文地址:https://www.cnblogs.com/sdikerdong/p/2404938.html
Copyright © 2011-2022 走看看