凡事从积极的态度做起
记述技术(Web/BI/biztalk infopath/sharepoint)、人、事

LCS使用RTC API 发送IM消息的WebService

星期四, 29 十二月 2005 02:23 by cleo

微软LCS 2005 With SP1 发布也有一段时间了。
1。准备工作:安装RTC Client API
http://msdn.microsoft.com/downloads/list/clientapi.asp

Microsoft Windows Real-Time Communications Client API SDK v1.3
The Microsoft Windows Real-Time Communications Software Development Kit 1.3 provides information, samples, and tools regarding the additional features of the Real-Time Communications 1.3 API. Additional features include: enhanced multiple points of presence support, support for Microsoft Office Live Communications Server 2005, additional client security options, and marshalling support.

Microsoft Real-time Communications Client Software Development Kit (SDK) v1.2
The Microsoft Real-time Communications Client SDK provides documentation, sample code and other tools that allow developers to build real-time communication applications, or integrate real-time communication functionality into existing applications.
Note: To execute samples or applications upon any development or test machine, install the SDK and then run RTCAPISETUP.EXE to install the Microsoft Real-time Communications Client API binaries. This executable can be found within the "Installation" sub-directory.


重要:请安装同时1.2和1.3 ,安装完下载后的MSI包之后,而且要运行
    :\Program Files\RTC Client API v1.2 SDK\INSTALLATION\RtcApiSetup.exe
    :\Program Files\RTC Client API v1.3 SDK\INSTALLATION\RtcApiSetup.exe
    :\Program Files\RTC Client API v1.3 SDK\INSTALLATION\RtcSxSPolicies.msi
   以上3个全部要安装,不是说安装1.3就不需要安装1.2了,而且要按照这个顺序,否则可能不能成功。
最好重新启动电脑吧,(把WebService发布到服务器时候记得也要在服务器上面安装哦)
2:编写Lib

using System;
using System.Collections.Generic;
using System.Text;
 
namespace CMS.LCSLib
{
 public class RTCClass
 {            
 
 private static void  createEnableProfile(RTCCORELib.RTCClient objRTCClient, string account, string password, string uri, string addr, string domain)
 {
 string s = "";
            s += "<provision key=\"{566E246F-9978-4434-83BF-3E47BCCFF466}\" name=\"" + domain + "\">";
            s += "<user account=\"" + account + "\" password=\"" + password + "\" uri=\"" + uri + "\" />";
            s += "<sipsrv addr=\"" + addr + "\" protocol=\"tcp\" role=\"proxy\">";
            s += "<session party=\"first\" type=\"pc2pc\" />";
            s += "<session party=\"first\" type=\"pc2ph\" />";
            s += "<session party=\"first\" type=\"im\" />";
            s += "</sipsrv>";
            s += "<sipsrv addr=\"" + addr + "\" protocol=\"tcp\" role=\"registrar\" />";
            s += "</provision>";
 
            RTCCORELib.IRTCProfile2 objProfile;//
            RTCCORELib.IRTCClientProvisioning2 objProvisioning;//
 
 try
 {
                objProvisioning = (RTCCORELib.IRTCClientProvisioning2)objRTCClient;
 
                objProfile = (RTCCORELib.IRTCProfile2)objProvisioning.CreateProfile(s);
 
 //EnableProfile
                objProvisioning.EnableProfile(objProfile, 0xF);
 //g_objProvisioning.EnableProfileEx(g_objProfile, 0x0000000F, 0x0000000F);
            }
 catch (Exception ex)
 {
                System.Diagnostics.EventLog.WriteEntry("LCSClass", ex.ToString());
            }
 return ;
 
        }
 
 public static void SendMessage(string strDestURI)
 {
 string account = @"tianchi\test";
 string password = "test";
 string uri = "sip:test@tianchi.local";
 string addr = "cms-biztalk.tianchi.local:5060";
 string domain = "tianchi.local";
 string strMsgHeader = null;
 string strMsg = "test from webservice";
 int lCookie = 0;
 string strDestName = null;
 try
 {
                  SendMessage(account, password, uri, addr, domain,
                       strMsgHeader, strMsg, lCookie, strDestURI, strDestName);
}
                  catch (Exception ex)
 {
                System.Diagnostics.EventLog.WriteEntry("LCSClass", ex.ToString());
            }
 return;
        }
 
 public static void SendMessage(string account, string password, string uri, string addr, string domain,
 string strMsgHeader, string strMsg, int lCookie, string strDestURI, string strDestName)
 {
 try
 {
                RTCCORELib.RTCClient objRTCClient;//
                RTCCORELib.IRTCSession objSession;
 //RTCCORELib.IRTCParticipant g_objParticipant;
 
 //'RTCClient needs to be initialized before any other method can be called on it.
                objRTCClient = new RTCCORELib.RTCClient();
                objRTCClient.Initialize();
 
 //createProfile & EnableProfile
                createEnableProfile(objRTCClient, account, password, uri, addr, domain);
 
 //'Create an IM session.
                objSession = objRTCClient.CreateSession(RTCCORELib.RTC_SESSION_TYPE.RTCST_MULTIPARTY_IM, null, null, 0);
 
 //'Add a participant to the IM session.
 //g_objParticipant = g_objSession.AddParticipant(strDestURI, strDestName);
                objSession.AddParticipant(strDestURI, strDestName);
 
 //'Send a message.
                objSession.SendMessage(strMsgHeader, strMsg, lCookie);
 //g_objSession.SendMessage(null, strMsg, 0);
            }
 catch (Exception ex)
 {
                System.Diagnostics.EventLog.WriteEntry("LCSClass", ex.ToString());
            }
        }
    }
}

3:编写WebService

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
 
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class RTCClass : System.Web.Services.WebService
{
 public RTCClass()
 {
 
 //Uncomment the following line if using designed components 
 //InitializeComponent(); 
    }
 
    [WebMethod]
 public void SendMessage(string account, string password, string uri, string addr, string domain,
 string strMsgHeader, string strMsg, int lCookie, string strDestURI, string strDestName)
 {
        CMS.LCSLib.RTCClass.SendMessage( account,  password,  uri,  addr,  domain,
             strMsgHeader,  strMsg,  lCookie,  strDestURI,  strDestName);
 return ;
    }
 /**//// <summary>
 /// 发送一个测试消息给某个用户
 /// </summary>
 /// <param name="strDestURI">格式:sip:cleo@tianchi.local</param>
    [WebMethod]
 public void SendMessageTest(string strDestURI)
 {      
        CMS.LCSLib.RTCClass.SendMessage( strDestURI);
 return;
    }
 
}

关于RTCCORELib.dll 引用问题
++++++++++++++++++++++++++++++++++++++++
在项目里面引用DLL的时候,
路径可能是:C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Networking.RtcDll_6595b64144ccf1df_5.2.2.1_x-ww_d6bd8b93\RTCCORELib.dll
你在\WINDOWS\WinSxS\x86_Microsoft.Windows.Networking.RtcDll_XXXXX之类的目录里面找就可以,
你也可以搜索RTCCORELib.dll
注意在SDK安装的时候,要关闭其它程序,尤其是Messager之类的,否则可能会造成找不到RTCCORELib.dll

posted on 2005-12-29 10:23 无为而为-凡事从积极的态度做起 阅读(3754) 评论(53) 编辑 收藏 所属分类: exchange/lcs/RTCWebService

评论
#1楼 2006-03-04 22:08 docula [未注册用户]

我下载并安装了两个sdk,可是创建web项目后,添加引用时在com选项中却看不到RTCCORELib,不知为何,请指教,多谢!   回复 引用 查看

#2楼 [楼主] 2006-03-06 09:09 无为而为

路径可能是:C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Networking.RtcDll_6595b64144ccf1df_5.2.2.1_x-ww_d6bd8b93\RTCCORELib.dll
你在\WINDOWS\WinSxS\x86_Microsoft.Windows.Networking.RtcDll_XXXXX之类的目录里面找就可以,
你也可以搜索RTCCORELib.dll   回复 引用 查看

#3楼 2006-03-07 11:09 少辉 [未注册用户]

请教一个问题,当webservice 调用了 CMS.LCSLib.rtccalss 到了objRTCClient.Initialize()这句时就出错了,没有执行下去.在web.config中 设置了"<identity impersonate="true" user="domain\用户名" password="password" />",也不行.
在winform直接调用CMS.LCSLib.rtccalss 就可以.如何解决这个问题.   回复 引用 查看

#4楼 [楼主] 2006-03-07 14:24 无为而为

应该是权限问题,你把应用程序池的帐号改成超管试试看。
回复 引用 查看

#5楼 2006-03-09 21:52 少辉 [未注册用户]

还是有问题,在调试中,还是会在objRTCClient.Initialize()退出.不知为何原因了.   回复 引用 查看

#6楼 [楼主] 2006-03-09 23:03 无为而为

不知道你有没有注意到这一句话:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
重要:请安装同时1.2和1.3 ,安装完下载后的MSI包之后,而且要运行
:\Program Files\RTC Client API v1.2 SDK\INSTALLATION\RtcApiSetup.exe
:\Program Files\RTC Client API v1.3 SDK\INSTALLATION\RtcApiSetup.exe
:\Program Files\RTC Client API v1.3 SDK\INSTALLATION\RtcSxSPolicies.msi
最好重新启动电脑吧,(把WebService发布到服务器时候记得也要在服务器上面安装哦)
++++++++++++++++++++++++++++++++++++++++   回复 引用 查看

#7楼 2006-03-10 19:01 少辉 [未注册用户]

问题搞定了,是引用的rtd.dll的问题,用了1.2的版本就没问题了,谢谢你   回复 引用 查看

#8楼 2006-03-14 14:37 perfwell [未注册用户]

问题搞定了,是引用的rtd.dll的问题,用了1.2的版本就没问题了,谢谢你??????????????????什么意思,能不能说清楚点,我和你一样的问题????
回复 引用 查看

#9楼 2006-03-14 14:51 perfwell [未注册用户]

非要装1.3吗??我没有1.3能不能发个我???fubin130@gmail.com   回复 引用 查看

#10楼 2006-03-14 18:09 cleo [未注册用户]

主贴不是有微软网站的下载连接吗?   回复 引用 查看

#11楼 2006-03-20 16:29 perfwell [未注册用户]

好像不能连继发多条消息,是不是有什么对像要关了重开???   回复 引用 查看

#12楼 [楼主] 2006-03-20 16:54 无为而为

怎么算是连续发多条消息?
会不会是你看错了?
在相同用户给你发连续的消息时候是不会新开窗口的,多条消息会在一个窗口显示,你仔细看看。   回复 引用 查看

#13楼 2006-04-26 10:22 Crocodile [未注册用户]

发多条消息是指服务器同时给多个人发消息,如果针对一个人时是可以发多条的,如果对多个人就不行了,应该是有对象要关闭重开!
sendmessage 的strMsgHeader参数都有那些格式,我想 用网页式的超链:隐藏地址,点击消息进行连接!谁知道怎么做!急啊。。。。。。。。。。。   回复 引用 查看

#14楼 [楼主] 2006-04-26 12:12 无为而为

@Crocodile
多个人发送相同的消息吗?
应该调用多次objSession.AddParticipant(strDestURI, strDestName);
就可以了吧。
office communicator(IM客户端)现在还不支持直接点击的超级链接吧,(默认的时候连传送超级链接地址都是禁止的,需要停止一个消息过滤器)。   回复 引用 查看

#15楼 2006-04-26 15:41 Crocodile [未注册用户]

@无为而为
在一个时间点,给不同的人发不同的消息;
objSession.AddParticipant(strDestURI, strDestName)只是进行多人会话,只给一个发消息:strDestURI是个帐号组成的数组
for (int j = 0; j < strDestURI.Length; j++)
{
objSession.AddParticipant(strDestURI[j], strDestName);
for (int i = 0; i < 10; i++)
objSession.SendMessage(strMsgHeader, strMsg + j.ToString(), lCookie);
}
结果消息只有一个人收到!不能解决同时给多个人发多个不同消息!!郁闷中。。。。
回复 引用 查看

#16楼 2006-05-18 16:49 wang [未注册用户]

程序运行后消息收不到是什么原因啊??   回复 引用 查看

#17楼 [楼主] 2006-05-18 22:12 无为而为

@wang
一般不会运行成功又收不到消息的,你在发送的时候要Try捕获错误。
如果你不去捕获错误,有些错误你是看不到的。
我开始也莫名其妙的收不到,使用try之后,发现有些错误在里面,要多调试调试。   回复 引用 查看

#18楼 2006-06-07 01:03 windsor [未注册用户]

有没有人知道objRTCClient.Initialize()这句要执行成功的条件?在web应用中使用1.2的dll后消息发送成功了,但是同样的程序放到另一个一样环境中又不行了总是objRTCClient.Initialize()这句执行错误。而在winForm程序中调用的话就不会有这些问题。谁有这方面的经验吗?   回复 引用 查看

#19楼 2006-10-08 12:56 fenglei [未注册用户]

{"无法将类型为“RTCCORELib.RTCClientClass”的 COM 对象强制转换为接口类型“RTCCORELib.IRTCClient”。此操作失败的原因是对 IID 为“{07829E45-9A34-408E-A011-BDDF13487CD1}”的接口的 COM 组件调用 QueryInterface 因以下错误而失败: 不支持此接口 (异常来自 HRESULT:0x80004002 (E_NOINTERFACE))。"}   回复 引用 查看

#20楼 [楼主] 2006-10-09 10:20 无为而为

@windsor
@ fenglei
请千万要注意环境的安装顺序,就是我使用红色标出的部分,不过不是按照那个顺序安装就非常容易出现各种问题。   回复 引用 查看

#21楼 2006-10-10 14:07 fenglei [未注册用户]

现在非要安装SDK 1.2版吗?如果不安装1.2 而直接下载1.3 (RtcApiSdk.msi)行吗?   回复 引用 查看

#22楼 2006-10-10 14:12 fenglei [未注册用户]

求助,我现在把上述代码修改以后到本地,按照要求填写完成以后,提交到SendMessage的时候,消息捕捉不到
回复 引用 查看

#23楼 2006-10-10 14:55 fenglei [未注册用户]

@少辉
你是怎样解决的问题。我现在也遇到如此的问题,总是在objRTCClient.Initialize()退出
是否还要在web.Config设置
回复 引用 查看

#24楼 [楼主] 2006-10-10 17:57 无为而为

@fenglei,
我在强调一遍,一定要按照说明的次序全部安装一次,而不是说安装1.3就不需要按照1.2了。
回复 引用 查看

#25楼 2006-10-24 16:04 master[匿名] [未注册用户]

感谢楼主。。
问您个问题,这个程序的string account = @"tianchi\test";都要改成自己的吧,我的是string account = @"lcs\Mlyu";另外如果我的运行环境不在account的域lcs里会不会有影响
回复 引用 查看

#26楼 2006-10-24 16:06 master[匿名] [未注册用户]

现在我的效果是程序都能通过,但是没有消息被接收到,很迷惑   回复 引用 查看

#27楼 [楼主] 2006-10-24 23:23 无为而为

@master[匿名]
如果LCS上面没有account 这个用户,我估计发送可能不会成功。
因为这个WebService的作用就是使用account 的身份来发送一个消息给某个用户。
你给发送消息的代码Try一下试试看,有没有错误没有捕获。   回复 引用 查看

#28楼 2006-10-25 09:32 master[匿名] [未注册用户]

@无为而为
恩,原来是string s的地方格式写错了
现在能 objSession.AddParticipant(strDestURI, strDestName);就是邀请他参加对话,但是最后一步SendMessage的时候有时候没消息在oc上面显示,有时候提示HRESULT XXXXXX异常,谢谢
回复 引用 查看

#29楼 2006-10-29 01:57 Honest Walker [未注册用户]

赫赫,RTC sdk 1.3和LCS2005一起用有点问题。莫名其妙的。。。   回复 引用 查看

#30楼 2006-12-10 13:56 bin[匿名] [未注册用户]

试了下,正如前面的朋友说的,好像不能循环对一个发多条信息,不知有没有哪位朋友知道如何解决此问题,可以交流下。~   回复 引用 查看

#31楼 2006-12-30 14:03 李国涛 [未注册用户]

我一直在公司开发是RTC client 端,我想知道,RTC SERVER 和 RTC CLIENT 是不是差不多,为什么网站只能找到client api 却一个也找不到 server api,谁有rtc server api 源码,要是有的话,还有就是下载了RTC Client API v1.3或v1.2 可以共享一下吗?
请联系我:
QQ: 27843681
MSN:li_guotao@163.com
EMAIL:li_guotao@163.com
skype:li.guotao
贸易通:liguotao1
我真的很想知道,因为我公司公司的服务器端是用LINUX版的。
回复 引用 查看

#32楼 2007-01-04 10:22 newblog[匿名] [未注册用户]

为什么我的RTCCORELib里没有IRTCProfile2 只有IRTCProfile   回复 引用 查看

#33楼 [楼主] 2007-01-04 14:20 无为而为-凡事从积极的态度做起

@李国涛
LCS 有LINUX版?   回复 引用 查看

#34楼 2007-01-04 14:48 newblog[匿名] [未注册用户]

@无为而为-凡事从积极的态度做起
为什么我的RTCCORELib命名空间里只有IRTCProfile接口 而没有IRTCProfile2接口   回复 引用 查看

#35楼 [楼主] 2007-01-05 11:09 无为而为-凡事从积极的态度做起

@newblog[匿名]
不知道你有没有注意到这一句话:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
重要:请安装同时1.2和1.3 ,安装完下载后的MSI包之后,而且要运行
:\Program Files\RTC Client API v1.2 SDK\INSTALLATION\RtcApiSetup.exe
:\Program Files\RTC Client API v1.3 SDK\INSTALLATION\RtcApiSetup.exe
:\Program Files\RTC Client API v1.3 SDK\INSTALLATION\RtcSxSPolicies.msi
最好重新启动电脑吧,(把WebService发布到服务器时候记得也要在服务器上面安装哦)
++++++++++++++++++++++++++++++++++++++++
在项目里面引用DLL的时候,
路径可能是:C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Networking.RtcDll_6595b64144ccf1df_5.2.2.1_x-ww_d6bd8b93\RTCCORELib.dll
你在\WINDOWS\WinSxS\x86_Microsoft.Windows.Networking.RtcDll_XXXXX之类的目录里面找就可以,
你也可以搜索RTCCORELib.dll   回复 引用 查看

#36楼 2007-01-09 17:06 klkl[匿名] [未注册用户]

我在安装:\Program Files\RTC Client API v1.3 SDK\INSTALLATION\RtcApiSetup.exe 时出现如下错误:
Error 1931 The Windows Installer service cannot update the system file C:\WINDOWS\WinSxS\Manifests\ x86_Microsoft.Windows.Networking.RtcDll_6595b64144ccf1df_5.2.1002.3_x-ww_92561FCE.cat because the file is protected by Windows.
可以忽略然后继续安装,但安装完成后在C:\WINDOWS\WinSxS下搜索不到RTCCORELib.dll 请教是什么原因   回复 引用 查看

#37楼 2007-01-11 17:52 !!![匿名] [未注册用户]

@master[匿名]
现在我的效果是程序都能通过,但是没有消息被接收到,很迷惑
我现在也是同样的现象,有人能解决这种情况吗? 谢谢
回复 引用 查看

#38楼 2007-01-18 17:46 !!![匿名] [未注册用户]

把本人遇到的情况给大家共享:
1,安装RTC Client API时不要打开Windows Messager,实在不行就卸载,否则会有如下错误:
我在安装:\Program Files\RTC Client API v1.3 SDK\INSTALLATION\RtcApiSetup.exe 时出现如下错误:
Error 1931 The Windows Installer service cannot update the system file C:\WINDOWS\WinSxS\Manifests\ x86_Microsoft.Windows.Networking.RtcDll_6595b64144ccf1df_5.2.1002.3_x-ww_92561FCE.cat because the file is protected by Windows.
可以忽略然后继续安装,但安装完成后在C:\WINDOWS\WinSxS下搜索不到RTCCORELib.dll 请教是什么原因
2,API安装成功,程序里遇到如下错误:的接口的 COM 组件调用 QueryInterface 因以下错误而失败,或者添加COM组件是看不到1.2或1.3.
此时可以在开始--运行里用regsvr32注册C:\WINDOWS\WinSxS\Manifests\ x86_Microsoft.Windows.Networking.RtcDll_6595b64144ccf1df_5.2.1002.3_x-ww_92561FCE里的相应组件   回复 引用 查看

#39楼 2007-01-31 13:36 NATHAN [未注册用户]

我用的sdk是1.3,为什么生成的客户端程序确实1.2的呢?1.2不支持2000吧,我的程序不能在2000下运行!请高手指点,该怎么做才能生成1.3的程序呢??   回复 引用 查看

#40楼 [楼主] 2007-02-01 10:30 无为而为-凡事从积极的态度做起

@NATHAN
把主贴看仔细点吧,1.3 和1.2要同时安装的。   回复 引用 查看

#41楼 2007-04-02 17:24 Blueicetodo [未注册用户]

我也是同样的问题
{"无法将类型为“RTCCORELib.RTCClientClass”的 COM 对象强制转换为接口类型“RTCCORELib.IRTCClient”。此操作失败的原因是对 IID 为“{07829E45-9A34-408E-A011-BDDF13487CD1}”的接口的 COM 组件调用 QueryInterface 因以下错误而失败: 不支持此接口 (异常来自 HRESULT:0x80004002 (E_NOINTERFACE))。"}
我的安装顺序如下:
安装1.2
安装1.3
重启电脑
运行
:\Program Files\RTC Client API v1.2 SDK\INSTALLATION\RtcApiSetup.exe
:\Program Files\RTC Client API v1.3 SDK\INSTALLATION\RtcApiSetup.exe
:\Program Files\RTC Client API v1.3 SDK\INSTALLATION\RtcSxSPolicies.msi
然后找不到RTCCORELib.dll,
而后运行tlbimp rtcdll.dll得到了RTCCORELib.dll,
然后运行程序就出现上面说的问题,请楼主帮忙,我的联系方式:lixintodo@hotmail.com   回复 引用 查看

#42楼 2007-04-03 11:15 Blueicetodo [未注册用户]

又按照顺序安装了一遍,现在程序能正常通过,但收不到消息,我的开发环境与lcs不在一个域里面,不知道是否有问题?   回复 引用 查看

#43楼 [楼主] 2007-04-03 11:46 无为而为-凡事从积极的态度做起

@Blueicetodo
try跟踪看看有没有例外抛出?   回复 引用 查看

#44楼 2007-04-04 11:39 Blueicetodo [未注册用户]

捕捉到 System.Runtime.InteropServices.COMException
Message="异常来自 HRESULT:0x80EE002A"
Source="Interop.RTCCORELib"
ErrorCode=-2131886038
StackTrace:
在 RTCCORELib.IRTCSession.SendMessage(String bstrMessageHeader, String bstrMessage, Int32 lCookie)
在 CMS.LCSLib.RTCClass.SendMessage(String account, String password, String uri, String addr, String domain, String strMsgHeader, String strMsg, Int32 lCookie, String strDestURI, String strDestName) 位置 G:\Blueicetodo\Code\Business\Lcslib.cs:行号 94   回复 引用 查看

#45楼 2007-04-04 14:37 Blueicetodo [未注册用户]

补充一点就是我的LCS服务器是用的TLS验证,企业版,5061端口,不知道string s=""那段应该怎么写,还有证书什么的   回复 引用 查看

#46楼 2007-04-09 15:25 lq [未注册用户]

我的程序在XP上能执行,但是在2003上执行
private static void createEnableProfile(RTCCORELib.RTCClient objRTCClient, string account, string password, string uri, string addr, string domain)
{
string s = "";
s += "<provision key=\"{566E246F-9978-4434-83BF-3E47BCCFF466}\" name=\"" + domain + "\">";
s += "<user account=\"" + account + "\" password=\"" + password + "\" uri=\"" + uri + "\" />";
s += "<sipsrv addr=\"" + addr + "\" protocol=\"tcp\" role=\"proxy\">";
s += "<session party=\"first\" type=\"pc2pc\" />";
s += "<session party=\"first\" type=\"pc2ph\" />";
s += "<session party=\"first\" type=\"im\" />";
s += "</sipsrv>";
s += "<sipsrv addr=\"" + addr + "\" protocol=\"tcp\" role=\"registrar\" />";
s += "</provision>";
RTCCORELib.IRTCProfile2 objProfile;//
RTCCORELib.IRTCClientProvisioning2 objProvisioning;//
try
{
objProvisioning = (RTCCORELib.IRTCClientProvisioning2)objRTCClient;
objProfile = (RTCCORELib.IRTCProfile2)objProvisioning.CreateProfile(s);
//EnableProfile
objProvisioning.EnableProfile(objProfile, 0xF);
//g_objProvisioning.EnableProfileEx(g_objProfile, 0x0000000F, 0x0000000F);
}
catch (Exception ex)
{
System.Diagnostics.EventLog.WriteEntry("LCSClass", ex.ToString());
}
return ;
}
中 objProvisioning = (RTCCORELib.IRTCClientProvisioning2)objRTCClient;这段代码出错,而且错误不能被捕获.
请帮忙,谢谢!
回复 引用 查看

#47楼 2007-06-12 17:28 李宏波 [未注册用户]

各位大虾,你们谁有可以用的 RTCCORELib.dll 发一个给小弟好吗?最近在研究 LCS 头都疼了,谢谢先~
我的邮箱 lemon_bobo520@163.com
lemon_bobo520@hotmail.com
lemon_bobo520@yahoo.com.cn   回复 引用 查看

#48楼 2007-07-25 18:52 vv [未注册用户]

bgg   回复 引用 查看

#49楼 2007-07-25 18:55 zcr [未注册用户]

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using RTCCORELib;
using System.Configuration;
namespace MsnLCSLib
{
public class LCSClass
{
private RTCCORELib.RTCClientClass rtcClientClass;
private RTCCORELib.IRTCSession iRTCSession;
private RTCCORELib.IRTCClientProvisioning2 objProvisioning;
private RTCCORELib.IRTCProfile objProfile;
private string _MsgTxt;
private string _strDestURI = "";
private string _MsnServerIP;
public LCSClass()
{
rtcClientClass = new RTCCORELib.RTCClientClass();
iRTCSession = null;
objProvisioning = null;
objProfile = null;
_MsgTxt = "";
_strDestURI = "";
try
{
string serverip=ConfigurationSettings.AppSettings["MsnSeverIp"].ToString().Trim();
string serveripport=ConfigurationSettings.AppSettings["MsnSeverIpPort"].ToString().Trim();
if (serverip != "" && serveripport != "")
_MsnServerIP = serverip + ":" + serveripport;
else
_MsnServerIP = "127.0.0.1:5060";
}
catch
{
_MsnServerIP = "127.0.0.1:5060";
}
}
public LCSClass(string msnServerAdr)
{
rtcClientClass = new RTCCORELib.RTCClientClass();
iRTCSession = null;
objProvisioning = null;
objProfile=null;
_MsgTxt = "";
_strDestURI = "";
_MsnServerIP = msnServerAdr;
}   回复 引用 查看

#50楼 2007-07-25 18:56 zcr [未注册用户]

public void SendMessage(string account, string password, string uri, string strMsg, string strDestURI)
{
rtcClientClass.Initialize();
rtcClientClass.IRTCEventNotification_Event_Event
+= new RTCCORELib.IRTCEventNotification_EventEventHandler(Client_IRTCEventNotification_Event_Event);
rtcClientClass.EventFilter = 33554431;
rtcClientClass.ListenForIncomingSessions = RTC_LISTEN_MODE.RTCLM_DYNAMIC;
objProvisioning = (RTCCORELib.IRTCClientProvisioning2)rtcClientClass;
objProvisioning.GetProfile(account, password, uri, _MsnServerIP, 2, 0);
this._MsgTxt = strMsg;
this._strDestURI = strDestURI;
}
public void SendMessage(string strMsg, string strDestURI)
{
string adminlogin = ConfigurationSettings.AppSettings["MsnSysLoginName"].ToString().Trim();
string adminloginpwd = ConfigurationSettings.AppSettings["MsnSysLoginPwd"].ToString().Trim();
string Sipadminlogin="sip:"+adminlogin;
SendMessage(adminlogin, adminloginpwd, Sipadminlogin, strMsg, strDestURI);
}
private void SendMsg()
{
if (iRTCSession == null)
{
iRTCSession = rtcClientClass.CreateSession(RTCCORELib.RTC_SESSION_TYPE.RTCST_MULTIPARTY_IM, null, null, 0);
}
RTCCORELib.IRTCParticipant iRTCParticipant = iRTCSession.AddParticipant(this._strDestURI.Trim(), "");
iRTCSession.SendMessage("text/plain", this._MsgTxt, 0);
}
/// <summary>
/// IRTCEventNotification_Event_Event事件
/// </summary>
/// <param name="RTCEvent"></param>
/// <param name="pEvent"></param>
void Client_IRTCEventNotification_Event_Event(RTC_EVENT RTCEvent, object pEvent)
{
switch (RTCEvent)
{
case RTC_EVENT.RTCE_PROFILE:
{
ProfileEvent((RTCCORELib.IRTCProfileEvent2)pEvent); // ProfileEvent事件
break;
}
case RTC_EVENT.RTCE_SESSION_OPERATION_COMPLETE:
{
ClearObj();//释放对象
break;
}
}
}
/// <summary>
/// // ProfileEvent事件
/// </summary>
/// <param name="pEvent"></param>
private void ProfileEvent(RTCCORELib.IRTCProfileEvent2 pEvent)
{
switch (pEvent.EventType)
{
case RTC_PROFILE_EVENT_TYPE.RTCPFET_PROFILE_GET:
{
if (pEvent.StatusCode == 0)
{
objProfile = pEvent.Profile;
objProvisioning.EnableProfile(objProfile, 0xF);
SendMsg();
}
break;
}
}
}
private void ClearObj()
{
if (objProfile != null)
{
if (objProvisioning != null)
{
objProvisioning.DisableProfile(objProfile);
objProfile = null;
objProvisioning = null;
}
}
rtcClientClass.PrepareForShutdown();
rtcClientClass.Shutdown();
iRTCSession = null;
_MsgTxt = "";
_strDestURI = "";
}
回复 引用 查看

#51楼 2007-07-25 18:57 zcr [未注册用户]

/// <summary>
/// 返回所有Msn在线用户
/// </summary>
/// <returns></returns>
public DataTable GetMsnOnline()
{
return (new MsnLCSLib.BusData.DataLayerSQLServer()).GetMsnOnline();
}
/// <summary>
/// 返回所有Msn在线用户
/// </summary>
/// <returns></returns>
public DataTable GetMsnOnline(string MsnSeverIp, string MsnDbUser, string MsnDbPwd)
{
return (new MsnLCSLib.BusData.DataLayerSQLServer(MsnSeverIp, MsnDbUser, MsnDbPwd)).GetMsnOnline();
}
public DataTable CheckMsnOnline(string msnLogin)
{
return (new MsnLCSLib.BusData.DataLayerSQLServer()).CheckMsnOnline(msnLogin);
}
public string ReMsnSata(int Availability, int Activity)
{
string re = "-1";
if (Availability == 300 && Activity == 700)
{
re = "联机";
}
else if (Availability == 300 && Activity == 350)
{
re = "忙碌";
}
else if (Availability == 300 && Activity == 600)
{
re = "马上回来";
}
else if (Availability == 300 && Activity == 500)
{
re = "接听电话";
}
else if (Availability == 300 && (Activity == 100 || Activity == 250))
{
re = "离开";
}
else if (Availability == 300 && Activity == 450)
{
re = "外出就餐";
}
else if (Availability == 0 && Activity == 0)
{
re = "脱机";
}
return re;
}
}
}
回复 引用 查看

#52楼 2007-07-25 18:58 zcr [未注册用户]

供大家学习,,共同研究
有问题QQ:30967932联系   回复 引用 查看

#53楼 2007-07-25 19:06 zcr [未注册用户]

我是用在项目中消息自动提示功能。。
简单说明一下:
string adminlogin = ConfigurationSettings.AppSettings["MsnSysLoginName"].ToString().Trim();
string adminloginpwd = ConfigurationSettings.AppSettings["MsnSysLoginPwd"].ToString().Trim();
string Sipadminlogin="sip:"+adminlogin;
结合成一个sip:XXX@XX.XX 这个账号相当于QQ里面的1000号一样。。
就是系统消息提示账号。。
向某人发消息时,调用方法:SendMessage("消息内容",“接收人的Msn账号”);就可以了   回复 引用