运行腾讯通:安装腾讯通 服务器,客户端,服务器SDK
下载:
http://download.tech.qq.com/soft/17/21/45406/index.shtml
本实例也是通过查看RTX的SDK,才简单的弄了一下!
在网络上找到的也是简单的代码。不能完全理会!
给网络学RTX的朋友提供参考!
---------------------------------------------------------------------
版本:2008 Beta1 (8.0.054.201)
引用:Interop.RTXCAPILib.dll
Interop.RTXClient.dll
Interop.RTXSAPILib.dll
using RTXCAPILib;
using RTXSAPILib;
using RTXClient;
本文完全按照腾讯公司提供的Demo操作
------------------------------------------------------------------
VS 2005
1.新建网站 RTX_test
功能一:单点登录
前台:
<table style="position: relative">
<tr>
<td style="width: 100px">
服务器地址:</td>
<td style="width: 100px">
<asp:TextBox ID="txtServerIP" runat="server" Style="position: relative">127.0.0.1</asp:TextBox></td>
<td style="width: 122px">
AppServer端口:</td>
<td style="width: 100px">
<asp:TextBox ID="txtAppServerPort" runat="server" Style="position: relative">8006</asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px">
用户名:</td>
<td style="width: 100px">
<asp:TextBox ID="txtUserName" runat="server" Style="position: relative">wf</asp:TextBox></td>
<td style="width: 122px">
登录端口:</td>
<td style="width: 100px">
<asp:TextBox ID="txtServerPort" runat="server" Style="position: relative">8000</asp:TextBox></td>
</tr>
<tr>
<td align=center colspan="4" style="height: 26px">
<asp:Button ID="Button1" runat="server" Style="position: relative" Text="登录" OnClick="Button1_Click" /></td>
</tr>
</table>
后台:
using RTXCAPILib;
using RTXSAPILib;
using RTXClient;
protected void Button1_Click(object sender, EventArgs e)
{
//登录
RTXClient.RTXAPIClass ObjApi = new RTXAPIClass(); //创建一个客户端SDK主对象
RTXCAPILib.IRTXCRoot RTXCRoot = (RTXCAPILib.IRTXCRoot)ObjApi.GetObject("KernalRoot"); //通过主对象获取CRoot对象
try
{
string Account = txtUserName.Text; //帐号
string SessionKey = GetSessionKey(Account);//获取SessionKey
RTXCRoot.LoginSessionKey(txtServerIP.Text, Convert.ToInt16(txtServerPort.Text), Account, SessionKey); //SessionKey 登录
Response.Redirect("browinfo.aspx");
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
}
private string GetSessionKey(string Account) //服务器端代码
{
string SessionKey = "";
RTXSAPILib.RTXSAPIRootObj RootObj = new RTXSAPIRootObj(); //创建一个根对象
RTXSAPILib.RTXSAPIUserAuthObj UserAuthObj = RootObj.UserAuthObj; //创建一个用户认证对象
RootObj.ServerIP = txtServerIP.Text; //设置服务器IP
RootObj.ServerPort = Convert.ToInt16(txtAppServerPort.Text); //设置Appserver端口
try
{
SessionKey = UserAuthObj.GetSessionKey(Account); //通过用户认证对象获取SessionKey
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
return SessionKey; //返回SessionKey
}
功能二:查询企业信息
前台:
<body>
<form id="form1" runat="server">
<div>
<table style="position: relative">
<tr>
<td style="width: 100px; height: 39px;">
服务器地址:</td>
<td style="width: 100px; height: 39px;">
<asp:TextBox ID="txtSvrIP" runat="server" Style="position: relative">127.0.0.1</asp:TextBox></td>
<td style="width: 128px; height: 39px;">
AppServer端口:</td>
<td style="width: 100px; height: 39px;">
<asp:TextBox ID="txtSvrPort" runat="server" Style="position: relative">8006</asp:TextBox></td>
</tr>
</table>
</div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="position: relative"
Text="查询企业信息" />
<asp:TextBox ID="txtResult" runat="server" Style="position: relative" TextMode="MultiLine">查询企业信息</asp:TextBox>
</form>
</body>
后台:
RTXSAPILib.RTXSAPIRootObj RootObj; //声明一个根对象
protected void Page_Load(object sender, EventArgs e)
{
RootObj = new RTXSAPIRootObj(); //创建根对象
RootObj.ServerIP = txtSvrIP.Text; //设置服务器IP
RootObj.ServerPort = Convert.ToInt16(txtSvrPort.Text); //设置服务器端口
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
txtResult.Text = RootObj.GetEnterpriseInfo(); //获取企业信息
}
catch (Exception xe)
{
Response.Write(xe.Message.ToString());
}
}
功能三:发送消息提示
using RTXSAPILib;
using RTXClient;
<body>
<form id="form1" runat="server">
<table style="position: relative">
<tr>
<td style="width: 100px; height: 39px;">
服务器地址:</td>
<td style="width: 100px; height: 39px;">
<asp:TextBox ID="txtSvrIP" runat="server" Style="position: relative">127.0.0.1</asp:TextBox></td>
<td style="width: 128px; height: 39px;">
AppServer端口:</td>
<td style="width: 100px; height: 39px;">
<asp:TextBox ID="txtSvrPort" runat="server" Style="position: relative">8006</asp:TextBox></td>
</tr>
</table>
<div>
<table style="width: 502px; position: relative">
<tr>
<td style="width: 133px">
消息提醒接收者:</td>
<td style="width: 250px">
<asp:TextBox ID="txtReceivers" runat="server" Style="position: relative"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 133px">
息提醒标题:</td>
<td style="width: 250px">
<asp:TextBox ID="txtMsgTitle" runat="server" Style="position: relative"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 133px">
息提醒停留时间:</td>
<td style="width: 250px">
<asp:TextBox ID="txtTime" runat="server" Style="position: relative"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 133px">
消息内容:</td>
<td style="width: 250px">
<asp:TextBox ID="txtMsgContent" runat="server" Style="position: relative" TextMode="MultiLine"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 133px; height: 26px;">
</td>
<td style="width: 250px; height: 26px;">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="position: relative"
Text="发送" /></td>
</tr>
</table>
<br />
查询用户状态<br />
<table style="width: 445px; position: relative">
<tr>
<td style="width: 100px">
用户名:<asp:TextBox ID="txtUserName" runat="server" Style="position: relative"></asp:TextBox>
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Style="position: relative"
- 1
- 2
- 3
- 4
- 5
前往页