---++!! !JGSL_clientproxy %TOC{title="Contents:"}% %STARTINCLUDE% ---++ client proxy for server communicating with client | *Title* | client proxy for server communicating with client | | *Author(s)* | LiXizhi | | *Date* | 2008/12/25 | | *File* | script/kids/3DMapSystemNetwork/JGSL_clientproxy.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemNetwork/JGSL_clientproxy.lua"); local proxy = Map3DSystem.JGSL.ClientProxy:new({DefaultFile="your_client_neuron_filename.lua"}); </verbatim> ---+++ Member Functions ---++++ !ClientProxy:new <verbatim> proxy status local proxystate = { -- proxy is reset none = nil, -- waiting for server response waiting = 1, -- server already responded, the client can send message at anytime ready = 2, } ------------------------------------ a server proxy is used by client to communicate with a epoll server. ------------------------------------ local ClientProxy = { -- nil means we are ready to send a packet. state = proxystate.none, -- the last time the client sends message to a server proxy, this is measured by the local clock. LastSendTime, -- the last time the client receives message from the server, this is measured by the local clock. LastReceiveTime, -- default neuron file DefaultFile = "script/kids/3DMapSystemNetwork/JGSL_client.lua", -- proxy role UserRole = "guest", -- JID jid, -- the jabber client to use. if nil, JGSL.GetJC() is used. jc, -- whether we have signed in to the server and has its session key in cookies, SignedIn, -- cookies: nil or a table containing name value pairs, such as {sk="sessionkeyhere"} cookies, -- default server timeout time -- usually if the server is not responding in 20 seconds, we will report to user about connecion lost or unsuccessful. ServerTimeOut = 20000, }</verbatim> Map3DSystem.JGSL.ClientProxy = ClientProxy; __syntax__ <verbatim>function ClientProxy:new (o)</verbatim> __parameters__ | *o* | | ---++++ !ClientProxy:Reset it will send CS_Logout if old connection contains cookies __syntax__ <verbatim>function ClientProxy:Reset()</verbatim> ---++++ !ClientProxy:Send send a message to server using this proxy. * _param_ __msg__ : msg to send * _param_ __neuronfile__ : if nil, self.DefaultFile is used. __syntax__ <verbatim>function ClientProxy:Send(jid, msg, neuronfile)</verbatim> __parameters__ | *jid* | | | *msg* | msg to send | | *neuronfile* | | ---++++ !ClientProxy:OnRespond call this function whenever the proxy has a response from the server. it makes the proxy ready to send another message. __syntax__ <verbatim>function ClientProxy:OnRespond()</verbatim> ---++++ !ClientProxy:UpdateSessionKey update session key * _param_ __bInsertToCookie__ : if true, it will insert sk to cookies, so that sk will be sent along with all subsequent Send calls. __syntax__ <verbatim>function ClientProxy:UpdateSessionKey(sk)</verbatim> __parameters__ | *sk* | | ---++++ !ClientProxy:IsReady whether the proxy is in ready state ready state means that the proxy is connected and not waiting for response. __syntax__ <verbatim>function ClientProxy:IsReady()</verbatim> ---++++ !ClientProxy:MakeReady force the proxy to ready state __syntax__ <verbatim>function ClientProxy:MakeReady()</verbatim> ---++++ !ClientProxy:IsKeepAlive whether deltaTime is passed since the last time that we send message to server. if return true, we usually need to send a normal update to server to keep the client alive. * _param_ __deltaTime__ : in milliseconds. usually several times the normal update interval. If nil, self.KeepAliveInterval is used. __syntax__ <verbatim>function ClientProxy:IsKeepAlive(deltaTime)</verbatim> __parameters__ | *deltaTime* | in milliseconds. usually several times the normal update interval. If nil, self.KeepAliveInterval is used. | ---++++ !ClientProxy:IsTimeOut return true if we are not receiving server response for too long __syntax__ <verbatim>function ClientProxy:IsTimeOut()</verbatim> %STOPINCLUDE%
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2008-02-29
-
LiXizhi
Home
Site map
CCWeb web
HaqiTeen web
Main web
ParaEngine web
TWiki web
Main Web
Users
Groups
Index
Search
Changes
Notifications
RSS Feed
Statistics
导航页WebTopMenu
Preferences
开发指南
Getting Started
ParacraftSDK
NPL
MCML
NPL Reference Manual
美术Mod
Account
Log In
English
简体中文
簡體中文
E
dit
A
ttach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback