Groups
Groups
Sign in
Groups
Groups
wdk_api
Conversations
About
Send feedback
Help
WdkChatRoom利用缓存机制提高连接速度
0 views
Skip to first unread message
戴路
unread,
Dec 7, 2007, 1:41:16 AM
12/7/07
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to wdk_api
1 原理
WdkChatRoom工作过程中首先需要查询服务器地址,然后才能连接服务器,从而实现负载均衡。如果能够缓存曾经访问过服务器地址,直接连接服务
器,将提高连接速度。本文描述缓存地址的方法。
2 实现步骤
2.1 建立map保存聊天室到地址的映射
CMapStringToString m_id2site;//rtmp缓存
2.2 保存映射
每次login over时候,会回传3个参数:登陆结果、roomid、服务器地址,把roomid和服务器地址保存到映射表里面。
m_id2site[id] = local;
2.3 使用缓存
在onFlashReady时,登陆前,检查是否曾经进入过,如果是,就设置缓存的地址(SetRoomParam("rtmp=地址")),再执行登
录(调用LoginRoom),这样,flash控件就不会执行查询动作,从而提高登录速度。
CString rKey = "";
if (m_id2site.Lookup(id,rKey) != 0)
{
CString tmp = "rtmp="+rKey;
m_proxy->SetRoomParam(tmp);
}
int result = m_proxy->LoginRoom(DOMAN_UUSEE,authInfo,token);
Reply all
Reply to author
Forward
0 new messages