---++!! !JGSL_server %TOC{title="Contents:"}% %STARTINCLUDE% ---++ OBSOLETED use JGSL_grid instead: When a jabber server receives a message from the client, it will accept it or reject it. If accepted, it will reply so and create a JGSL_client_agent character on the server computer if it has never been created before. This JGSL_client_agent will be responsible to keep track of an active client on the server. | *Title* | OBSOLETED use JGSL_grid instead: When a jabber server receives a message from the client, it will accept it or reject it. If accepted, it will reply so and create a JGSL_client_agent character on the server computer if it has never been created before. This JGSL_client_agent will be responsible to keep track of an active client on the server. | | *Author(s)* | LiXizhi | | *Date* | 2007/11/6, revised by LiXizhi 2008.6.26 | | *File* | script/kids/3DMapSystemNetwork/JGSL_server.lua | ---+++ Description %T% __Sample Code__ <verbatim> NPL.load("(gl)script/kids/3DMapSystemNetwork/JGSL.lua"); </verbatim> ---+++ Member Functions ---++++ !JGSL_server.Reset <verbatim> server session key, it is regenerated each time we load a different world. JGSL_server.SessionKey = ParaGlobal.GenerateUniqueID(); server version JGSL_server.ServerVersion = 1; required client version JGSL_server.ClientVersion = 1; the agent of the current player JGSL_server.playeragent = nil; timer ID JGSL_server.TimerID = 17; contains all client and server agent creation and environmental action history. JGSL_server.history = { creations = {}, env = {}, }</verbatim> max number of creations in a message JGSL_server.max_creations_per_msg = 5; max number of env updates in a message JGSL_server.max_env_per_msg = 5; a timer that is enabled when there are active client connected to this server. should be smaller or equal to Map3DSystem.JGSL_client.NormalUpdateInterval to prevent duplicate group2 info to be sent for the same client. JGSL_server.TimerInterval = 3000; if a client is not responding in 20 seconds, we will make it inactive user and remove from active user list. JGSL_server.ClientTimeOut = 20000; if true, the game server is a dedicated server usually without any user interface. Pure server will use a different restart function. JGSL_server.IsPureServer = nil; a new character will be located at radius = miniSpawnRadius+math.sqrt(OnlineUserNum+1)*3; JGSL_server.miniSpawnRadius = 5; When the server has broadcasted this number of objects, the server will be automatically restarted; this is usually the setting for testing public server. JGSL_server.RestartOnCreateNum = tonumber(ParaEngine.GetAppCommandLineByParam("RestartOnCreateNum", "0")); client agents on server, where JGSL_server.agents[JID] = {agent}. JGSL_server.agents = {}; ------------------------------ public function ------------------------------ regenerate session and become a new server. This is usually called by Map3DSystem.JGSL.Reset() call this to reset the server to inital disconnected state where there is a new session key, no history, no timer, no agents. __syntax__ <verbatim>function JGSL_server.Reset()</verbatim> ---++++ !JGSL_server.MakeServerPassive stop the timer and clear the server creation history. call this function when there are no users connected. JGSL will be active as long as there is a new client connection to it. __syntax__ <verbatim>function JGSL_server.MakeServerPassive()</verbatim> ---++++ !JGSL_server.GetPlayerAgent ------------------------------ private functions ------------------------------ get the agent representing the current player. __syntax__ <verbatim>function JGSL_server.GetPlayerAgent()</verbatim> ---++++ !JGSL_server.GetAgent it will create the agent structure if it does not exist __syntax__ <verbatim>function JGSL_server.GetAgent(JID)</verbatim> __parameters__ | *JID* | | ---++++ !JGSL_server.CreateAgent create an agent. it will overwrite existing one, if any, with a newly created one. __syntax__ <verbatim>function JGSL_server.CreateAgent(JID)</verbatim> __parameters__ | *JID* | | ---++++ !JGSL_server.history.clear <verbatim> some statistics JGSL_server.statistics = { StartTime = ParaGlobal.GetDateFormat(nil)..ParaGlobal.GetTimeFormat(nil), OnlineUserNum = 0, VisitsSinceStart = 0, NumObjectCreated = 0, }</verbatim> clear all history. call this function when a server restart. __syntax__ <verbatim>function JGSL_server.history.clear()</verbatim> ---++++ !JGSL_server.history.AddCreations when the server receives some client updates that contains creations, it will save all clients' creations to an array. At normal update time, the server will broadcast previous creations to the clients. * _param_ __creations__ : an array of creation history * _param_ __fromJID__ : who added this creations. __syntax__ <verbatim>function JGSL_server.history.AddCreations(creations, fromJID)</verbatim> __parameters__ | *creations* | an array of creation history | | *fromJID* | | ---++++ !JGSL_server.history.AddEnvs when the server receives some client updates that contains env updates, it will save all clients' creations to an array. At normal update time, the server will broadcast previous envs to the clients. * _param_ __env__ : an array of env history * _param_ __fromJID__ : who added this env. __syntax__ <verbatim>function JGSL_server.history.AddEnvs(env, fromJID)</verbatim> __parameters__ | *env* | an array of env history | | *fromJID* | | ---++++ !JGSL_server.history.GetCreationsForClientAgent get an array of creations from the server creation history. * _param_ __agent__ : the agent for whom creations will be retrieved. In fact, it will return all creations who time is larger than agent.LastCreationHistoryTime, and whose agent.fromJID is different from the one in creation history. * _param_ __MaxCount__ : nil or max number of creations to return. This prevents sending too many in a single message. * _return_ ____ : return nil or an array of creations for sending back to the client agent __syntax__ <verbatim>function JGSL_server.history.GetCreationsForClientAgent(agent, MaxCount)</verbatim> __parameters__ | *agent* | the agent for whom creations will be retrieved. In fact, it will return all creations who time is larger than agent.LastCreationHistoryTime, and whose agent.fromJID is different from the one in creation history. | | *MaxCount* | | | *return* | return nil or an array of creations for sending back to the client agent | ---++++ !JGSL_server.history.GetEnvsForClientAgent get an array of creations from the server creation history. * _param_ __agent__ : the agent for whom creations will be retrieved. In fact, it will return all creations who time is larger than agent.LastEnvHistoryTime, and whose agent.fromJID is different from the one in creation history. * _param_ __MaxCount__ : nil or max number of creations to return. This prevents sending too many in a single message. * _return_ ____ : return nil or an array of creations for sending back to the client agent __syntax__ <verbatim>function JGSL_server.history.GetEnvsForClientAgent(agent, MaxCount)</verbatim> __parameters__ | *agent* | the agent for whom creations will be retrieved. In fact, it will return all creations who time is larger than agent.LastEnvHistoryTime, and whose agent.fromJID is different from the one in creation history. | | *MaxCount* | | | *return* | return nil or an array of creations for sending back to the client agent | ---++++ !JGSL_server.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 JGSL_server.ApplyCreations(creations)</verbatim> __parameters__ | *creations* | | ---++++ !JGSL_server.ApplyEnvs 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 JGSL_server.ApplyEnvs(env)</verbatim> __parameters__ | *env* | | ---++++ !JGSL_server.OnTimer a very slowly kicked timer that periodically check user status __syntax__ <verbatim>function JGSL_server.OnTimer()</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