Another milestone for the Quixie project — the support for Net class, partially compatible to FreeKE‘s implementation.
FreeKE was using DirectX7’s DirectPlay while Quixie is powered by cha0s’ free ChiSock network library. Quixie’s network capability runs on User-Datagram Protocol (UDP).
This means that one can create a real-time multiplayer game. Of course, everything is preliminary for now — the API could change; we also plan to exploit ChiSock in the built-in game engine of Quixie itself and not just in the scripting level.
Apparently, there seem to be no existing documentation for FreeKE’s Net class. So I am writing below a code snippet for creating a network session and joining one, which I hope is self-explanatory. (Calling any volunteer for the documentation ^^)
//sample of hosting a session function main() { Var:Boolean okay; Net:Host("I_am_server", 2, "nettest", okay) if (okay == true) { Var:String player, msg, msgs; Var:Boolean gotMsg; while (B1 == false) { Net:Check() Net:GetMessage(player, msg, gotMsg) if (gotMsg == true) { msgs = msgs + "\n" + msg; Screen:PrintString(msgs) } Screen:Render() } } else { Konsol:Message("Unable to create session.","Net Test") } }
Copy above and name it server.ks then copy below for client.ks.
//sample of joining a session function main() { Var:Boolean okay, sent; Net:Join("I_am_client", "nettest", "127.0.0.1", okay) Var:Number i; while (okay EQ true) { Net:Check() Net:Send(i, sent) Konsol:Log("sent " + sent) if (i < 20) { i++; } else { okay = false; } } }
For the sample code for client, Net:Check is optional -- Net:Check is only used when you are expecting a message.
Sadly, we failed to deliver a release this November due to random bugs that is quite hard to duplicate. To test the code above, download the latest source code from the SVN repository and compile a copy of Quixie.
~creek23
Leave a Reply to logrono Cancel reply