Script Question
by John Eric Miller · in Torque Game Engine · 04/19/2003 (7:08 pm) · 4 replies
What calls GameConnection::onConnect? I am trying to track the flow of the script when loading a mission. Does setting Game::Running to true fire it off?
#2
04/19/2003 (7:49 pm)
Thanks for the explanation! What in the script ultimately sets off this chain of events?
#3
%conn.connect($ServerInfo::Address)
calls the following method in netConnection.cc:
void NetConnection::connect(const NetAddress *address)
At this point the torque networking code takes care of making the connection and if it is successful then GameConnection::onConnect call is made.
Also, you can put extra args in the %conn.setConnectArgs(...) call and they will be passed through to onConnect(...)
For example you could have the following:
%conn.setConnectArgs( $Name, $SkinName)
and have onConnect as follows:
function GameConnection( %client, %name, %skinName)
04/19/2003 (8:24 pm)
Its been a little while since I traced through and looked at this code and script, but if I remember correctly%conn.connect($ServerInfo::Address)
calls the following method in netConnection.cc:
void NetConnection::connect(const NetAddress *address)
At this point the torque networking code takes care of making the connection and if it is successful then GameConnection::onConnect call is made.
Also, you can put extra args in the %conn.setConnectArgs(...) call and they will be passed through to onConnect(...)
For example you could have the following:
%conn.setConnectArgs( $Name, $SkinName)
and have onConnect as follows:
function GameConnection( %client, %name, %skinName)
#4
Although I wrote a wrapper function that does the same thing connect() did with the new connection method.
04/19/2003 (9:32 pm)
No, they redid the connection code.Although I wrote a wrapper function that does the same thing connect() did with the new connection method.
Associate Kevin Ryan
Top Meadow Inc.
void GameConnection::onConnectionEstablished(bool isInitiator)
which is in gameConnection.cc
Here is a very short sample of script from joinServerGui.gui that makes a connection from client to a server:
function JoinServerGui::join(%this) { cancelServerQuery(); %id = JS_serverList.getSelectedId(); // The server info index is stored in the row along with the // rest of displayed info. %index = getField(JS_serverList.getRowTextById(%id),6); if (setServerInfo(%index)) { %conn = new GameConnection(ServerConnection); %conn.setConnectArgs($pref::Player::Name); %conn.setJoinPassword($Client::Password); %conn.connect($ServerInfo::Address); } }It is the %conn.connect(...) call that sets off the chain of events that eventually results in GameConnection::onConnect being called if all goes well