---++!! !JGSL_client %TOC{title="Contents:"}% %STARTINCLUDE% ---++ The jabber client will send the first message to the server, and wait for the server's reply until the next message is sent. If the client does not receive any reply, it will assume that the connection is lost. | *Title* | The jabber client will send the first message to the server, and wait for the server's reply until the next message is sent. If the client does not receive any reply, it will assume that the connection is lost. | | *Author(s)* | LiXizhi | | *Date* | 2007/11/6 | | *File* | script/kids/3DMapSystemNetwork/JGSL_client.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemNetwork/JGSL.lua"); Map3DSystem.JGSL_client:Dump() </verbatim> ---+++ Member Functions ---++++ !client:new <verbatim> private: client state local clientstate = { -- client has been reset none = nil, -- contacting gateway gateway = 1, -- sending normal update with grid server normalupdate = 2, -- disconnected from server, because of time out. -- disconnected = 3, } local client = { -- client session key, it is regenerated each time we are connecting to a user server. SessionKey = ParaGlobal.GenerateUniqueID(), -- client version ClientVersion = 1, -- required server version ServerVersion = 1, -- player agent. playeragent = nil, -- server agents on client, where agents[jid] = {agent}. agents = {}, -- a pool of timed out agents timeoutagents = {}, -- jc instance. if nil, JGSL.GetJC will be used. jc = nil, -- the jid of this server. jid = nil, -- whether this client is emulated. IsEmulated = nil, -- LoginServer will be forced to login to this world regardless the current world. EmuUser_worldpath = nil, -- private: keep a reference to the world path. this is sent automatically and should not be modified by users. worldpath = nil, -- timer ID TimerID = 16, -- emulation timer ID EmuTimerID = 21, -- if a client shall only send a message to the server every 3 seconds and after it receives the last server message. -- if the client does not receive message from server within this time, it will continue to wait until ServerTimeOut NormalUpdateInterval = 3000, -- if the client does not receive any messages from the server for 10 seconds. It will send the normal update again. -- it is usually twice of NormalUpdateInterval. MaxNormalUpdateInterval = 6000, -- if the server is not responding in 20 seconds, we will report to user about connecion lost or unsuccessful. ServerTimeOut = 20000, -- if an agent is not active for this time, it will be removed from the scene AgentTimeOut = 20000, -- the gate way server proxy object gatewayProxy = nil, -- the grid node server proxies. mapping from grid node server key to proxy object gridnodeProxies = nil, -- we will need to connect to all grid node servers within 30 meters, as agent or observers. sense_radius = 30, state = clientstate.none, -- increased by one eact time a normal update is sent timeid = 1, }</verbatim> JGSL.client = client; -------------------------- public functions -------------------------- create a new instance of this class. if there is only one instance, just use the default JGSL_client object without calling new() method. * _param_ __o__ : if emulated, use new({IsEmulated=true, jid=jid}) __syntax__ <verbatim>function client:new (o)</verbatim> __parameters__ | *o* | if emulated, use new({IsEmulated=true, jid=jid}) | ---++++ !client:log output a log message __syntax__ <verbatim>function client:log(...)</verbatim> ---++++ !client:Dump dump the current JGSL status. __syntax__ <verbatim>function client:Dump()</verbatim> ---++++ !client:GetAgent it will create the agent structure if it does not exist __syntax__ <verbatim>function client:GetAgent(jid)</verbatim> __parameters__ | *jid* | | ---++++ !client:GetJC get the JC instance __syntax__ <verbatim>function client:GetJC()</verbatim> ---++++ !client:GetJID get the jid instance __syntax__ <verbatim>function client:GetJID()</verbatim> ---++++ !client:GetGatewayServerJID jid of the gateway server __syntax__ <verbatim>function client:GetGatewayServerJID()</verbatim> ---++++ !client:Send send a message to a given jid * _param_ __msg__ : msg to send * _param_ __neuronfile__ : if nil, self.DefaultFile is used. __syntax__ <verbatim>function client:Send(jid, msg, neuronfile)</verbatim> __parameters__ | *jid* | | | *msg* | msg to send | | *neuronfile* | | ---++++ !client:LoginServer login to a server with a known jid name if we have a previous connection with the same gateway, all grid nodes sessions are reused. and the function returns immediately. * _param_ __jid__ : should be a jid like "lixizhi@paraweb3d.com" __syntax__ <verbatim>function client:LoginServer(jid)</verbatim> __parameters__ | *jid* | should be a jid like "lixizhi | ---++++ !client:LogoutServer logout the current connected gateway and grid servers * _param_ __bSilent__ : if true, we shall inform the UI. __syntax__ <verbatim>function client:LogoutServer(bSilent)</verbatim> __parameters__ | *bSilent* | if true, we shall inform the UI. | ---++++ !client:PingGateway sent ping to gateway server to establish connection with it __syntax__ <verbatim>function client:PingGateway()</verbatim> ---++++ !client:QueryGateway get gateway round trip time for debugging purposes. __syntax__ <verbatim>function client:QueryGateway()</verbatim> ---++++ !client:GetServerInfo get a ready only copy of currently connected server info table. it will return nil if not connected yet. __syntax__ <verbatim>function client:GetServerInfo()</verbatim> ---++++ !client:GetPlayerAgent -------------------------- private functions: -------------------------- get the agent representing the current player. __syntax__ <verbatim>function client:GetPlayerAgent()</verbatim> ---++++ !client:OnTimerEmu a timer that periodically send messages for emulated users __syntax__ <verbatim>function client:OnTimerEmu()</verbatim> ---++++ !client:OnTimer a timer that periodically send messages __syntax__ <verbatim>function client:OnTimer()</verbatim> ---++++ !client:ApplyCreations when some remote user creations are received by this computer, it will be applied in this world, however, without writing into the history. __syntax__ <verbatim>function client:ApplyCreations(creations)</verbatim> __parameters__ | *creations* | | ---++++ !client:ApplyEnvs when some remote user env updates are received by this computer, it will be applied in this world, however, without writing into the history. __syntax__ <verbatim>function client:ApplyEnvs(env)</verbatim> __parameters__ | *env* | | ---++++ !client:VerifySessionKey verify the session key in the message is the same as the gateway's session key __syntax__ <verbatim>function client:VerifySessionKey(msg)</verbatim> __parameters__ | *msg* | | ---++++ !client:FindBestGridProxy get available best server grid proxy for a given world path. a best grid proxy is a proxy that is smallest in size. * _param_ __worldpath__ : the world that the grid node is in. * _param_ __x__ :, y, z: a position that the grid node contains. * _param_ __IsObserver__ : true if we are just getting for an observer node. __syntax__ <verbatim>function client:FindBestGridProxy(worldpath, x, y, z)</verbatim> __parameters__ | *worldpath* | the world that the grid node is in. | | *x* | | | *y* | | | *z* | | ---++++ !client:RemoveGridProxy remove grid proxy __syntax__ <verbatim>function client:RemoveGridProxy(proxy)</verbatim> __parameters__ | *proxy* | | ---++++ !client:CreateGridNodeProxy Create a connected grid node server proxy, each grid node is responsible for simulating a specific region in the world. * _param_ __msg__ : the reply NPL message from SC_Login_Reply. It should contain grid node session key and info {gk, gjid, gx,gy,gsize, worldpath} * _return_ ____ : return the proxy object if succeeded __syntax__ <verbatim>function client:CreateGridNodeProxy(msg)</verbatim> __parameters__ | *msg* | the reply NPL message from SC_Login_Reply. It should contain grid node session key and info {gk, gjid, gx,gy,gsize, worldpath} | ---++++ !client:SendNormalUpdate send a normal update packet to the grid node containing the request location. if no grid node connection is available for the region, we will ask the gateway for it. __syntax__ <verbatim>function client:SendNormalUpdate()</verbatim> ---++++ !client:HandleMessage handle server messages __syntax__ <verbatim>function client:HandleMessage(msg)</verbatim> __parameters__ | *msg* | | %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