Game Development Community

commandToClient doesn't seem to call remote procedure right away

by Isidoros · in Torque Game Engine · 04/06/2009 (10:04 am) · 1 replies

I am studying common/server/clientConnection.cs script. In function GameConnection::OnConnect() there is a call to messageClient(). The last function is where we call commandToClient():

function messageClient(%client, %msgType, %msgString, %a1,..)
{   
  commandToClient(%client, 'ServerMessage', %msgType, %msgString, %a1,...);
}

I was expecting clientCmdServerMessage() to be the next called function.

The log file shows that clientCmdServerMessage comes when the program leaves onConnect() function.

Why this happen?

Part of log file:
....
Entering GameConnection::onConnect(1298, Sid_Iron)
        Entering (null)::messageClient(1298, 5, , You do not have the correct version of 3DGPAI1 client or the related art needed to play...mplampla mpla)
        Leaving (null)::messageClient - return 
        Entering (null)::sendLoadInfoToClient(1298)
            Entering (null)::messageClient(1298, 2, , Book B)
          ...
          ...
Leaving GameConnection::onConnect - return 

Leaving (null)::LaunchGame - return 
Mapping string: ServerMessage to index: 0
Mapping string: MsgConnectionError to index: 1
Entering (null)::clientCmdServerMessage(5 MsgConnectionError, , You do not have the correct version of 3DGPAI1 client or the related art needed to play...mplampla mpla)
.
...

#1
04/06/2009 (12:06 pm)
the purpose of a commandToClient is to call a function on a remote client connected via the internet, and when running in "standalone" mode, a single executable is acting simultaneously as client and server, and emulating the network between them. so the commands are placed in a queue and processed all at once during the game loop.

in general, you should assume that an arbitrary amount of time may pass between issuing a remote command and the remote command actually executing. in practise this delay is quite small, on the order of a handful of milliseconds.