Description: server+client: sends a part of a global var array immediately
Parameter: STRING* varname name of the global var array var vFrom first index var vTo last index
max. 250 entries at one time 0.249 or 10100..10349
Example:
var Array[500]; function evServer(vType, sData) { diag("\nReceive server event:"); if (vType == GSTNet_EvTypeConnect ) { diag("\nNew client connected. ClientId:"); diag(sData); GSTNet_SendVar("StartClients"); GSTNet_SendArray("Array",0,250); // send array immediately after client connect } }
function main() { ifdef srv; GSTNet_StartServer(2300,1); GSTNet_Events(GSTNet_EventServer, "evServer"); //start a function, which demonstrates global vars Array[0]=200; // only server sets the array values Array[1]=200; Array[2]=400; Array[249]=300; endif;
// start client if srv is set in commandline GSTNet_StartClient(server_name,2300,1); //server event connect is fired GSTNet_Events(GSTNet_EventClient, "evClient"); while(GSTNetId==0) {wait(1);} // client rceives from server the array values GSTNet_Synchronize(); wait(-0.5); test(); GSTNet_TrackVar("Counter"); draw_red_rect(Array[0],Array[1],Array[2],Array[249]); //array values are updated from server array on connected client }
Downloads on my website
Andreas GSTools - Home of GSTScript 0.9.8: lua scripting for A6/7/8 GSTNet 0.7.9.20: network plugin for A6/7/8 GSTsqlite 1.3.7: sql database plugin for A6/7/8 3DGS Codebase: 57 snippets || 3DGS Downloads: 248 files