ellie-idb / blocklandjs

BlocklandJS - a implementation of V8 in Blockland. Bad code included.
2 stars 0 forks source link

Add support for serverCmds and clientCmds #22

Closed Elletra closed 6 years ago

ellie-idb commented 6 years ago

Calling commandToClient/commandToServer requires to use of a constructed string.

var string = String.fromCharCode(0x01) + ts_func("getTag")("ourCmd");

Something along those lines You must have whatever character 0x01 corresponds to as the first part of the string-- this is used in Torque internally to verify that it is a "tag" type.

Elletra commented 6 years ago

what about defining them?

ellie-idb commented 6 years ago

Defining client and server functions is pretty simple.

function myClientCmdCallback() { print(arguments[0]); }
ts.expose(myClientCmdCallback, "", "clientCmdCallback");

function myServerCmdCallback() { print(arguments[0]);}
ts.expose(myServerCmdCallback, "", "serverCmdCallback");