relay send message to offline user - communicator 2007

本文介绍使用OC客户端通过Automation API发送离线消息的方法。包括启动会话及发送文本内容的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

 

转载于:https://www.cnblogs.com/sdikerdong/archive/2012/03/18/2404938.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值