{"id":208,"date":"2010-11-30T23:26:59","date_gmt":"2010-11-30T15:26:59","guid":{"rendered":"http:\/\/konsolscript.sf.net\/web\/?p=208"},"modified":"2010-12-01T00:28:13","modified_gmt":"2010-11-30T16:28:13","slug":"quixie-now-supports-net-class","status":"publish","type":"post","link":"http:\/\/konsolscript.sourceforge.net\/web\/2010\/11\/30\/quixie-now-supports-net-class\/","title":{"rendered":"Quixie now supports Net class"},"content":{"rendered":"<p>Another milestone for the Quixie project &#8212; the support for Net class, partially compatible to <a href=\"http:\/\/sourceforge.net\/apps\/mediawiki\/konsolscript\/index.php?title=FreeKE\" title=\"Free KonsolScript Engine\">FreeKE<\/a>&#8216;s implementation.<\/p>\n<p>FreeKE was using DirectX7&#8217;s DirectPlay while Quixie is powered by cha0s&#8217; free <a href=\"http:\/\/www.freebasic.net\/forum\/viewtopic.php?t=8454\" title=\"ChiSock Socket Library\">ChiSock network library<\/a>. Quixie&#8217;s network capability runs on <a href=\"http:\/\/en.wikipedia.org\/wiki\/User_Datagram_Protocol\">User-Datagram Protocol (UDP)<\/a>.<\/p>\n<p>This means that one can create a real-time multiplayer game. Of course, everything is preliminary for now &#8212; 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.<\/p>\n<p>Apparently, there seem to be no existing documentation for FreeKE&#8217;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 ^^)<\/p>\n<pre>\/\/sample of hosting a session\r\nfunction main() {\r\n    Var:Boolean okay;\r\n    Net:Host(\"I_am_server\", 2, \"nettest\", okay)\r\n    \r\n    if (okay == true) {\r\n        Var:String player, msg, msgs;\r\n        Var:Boolean gotMsg;\r\n        while (B1 == false) {\r\n            Net:Check()\r\n            Net:GetMessage(player, msg, gotMsg)\r\n            \r\n            if (gotMsg == true) {\r\n                msgs = msgs + \"\\n\" + msg;\r\n                Screen:PrintString(msgs)\r\n            }\r\n            Screen:Render()\r\n        }\r\n    } else {\r\n        Konsol:Message(\"Unable to create session.\",\"Net Test\")\r\n    }\r\n}<\/pre>\n<p>Copy above and name it <b>server.ks<\/b> then copy below for <b>client.ks<\/b>.<\/p>\n<pre>\/\/sample of joining a session\r\nfunction main() {\r\n    Var:Boolean okay, sent;\r\n    Net:Join(\"I_am_client\", \"nettest\", \"127.0.0.1\", okay)\r\n    Var:Number i;\r\n    while (okay EQ true) {\r\n        Net:Check()\r\n        Net:Send(i, sent)\r\n        Konsol:Log(\"sent \" + sent)\r\n        if (i < 20) {\r\n            i++;\r\n        } else {\r\n            okay = false;\r\n        }\r\n    }\r\n}<\/pre>\n<p>For the sample code for client, <b>Net:Check<\/b> is optional -- <i>Net:Check<\/i> is only used when you are expecting a message.<\/p>\n<p>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.<\/p>\n<p>~creek23<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Another milestone for the Quixie project &#8212; the support for Net class, partially compatible to FreeKE&#8216;s implementation. FreeKE was using DirectX7&#8217;s DirectPlay while Quixie is powered by cha0s&#8217; free ChiSock network library. Quixie&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[34,9],"_links":{"self":[{"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/posts\/208"}],"collection":[{"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/comments?post=208"}],"version-history":[{"count":1,"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/posts\/208\/revisions"}],"predecessor-version":[{"id":209,"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/posts\/208\/revisions\/209"}],"wp:attachment":[{"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/media?parent=208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/categories?post=208"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/konsolscript.sourceforge.net\/web\/wp-json\/wp\/v2\/tags?post=208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}