ShiVa3D
rmi xml example (xml network communication)
rmi xml example (xml network communication)
by Cheramu » 27 May 2012, 21:57
I'm currenly using for my xml communications with the backend. Feel free to use and modify.
It will translate xml send from the server to a method call within you're game.
How to use
You can do postEvent/sendEvent/sendEventImmediate followed by the method params.
See the example below for the xml format the back-end must send.
You can use the following to send a request to you're server
or use the local one if you have local stored xml that must call a method
Settings
Set the sServeradress variable or look in the init for the envoirement variable in AI_COMMAND
Example
You send een ping event to you're backend and get a pong response
--sXml
<s>ping</s>
--sExml
<cs>
<c t="sendEvent">
<p>Controller</p>
<p>onError</p>
<p>check youre internet connection</p>
</c>
</cs>
Youre backend sends the following back.
<cs>
<c t="postEvent">
<p>2</p>
<p>Controller</p>
<p>onLog</p>
<p>pong/p>
</c>
</cs>
the AI_COMMAND will call you're handler
todo
adding some data options like csv <c/>sendEvent,onLog,<c/>
to add https / http options
tips
You probelly have the logic functions of you're game, so make a handler that does the string conversion and calls that function.
Encode you're xml,
It will translate xml send from the server to a method call within you're game.
How to use
You can do postEvent/sendEvent/sendEventImmediate followed by the method params.
See the example below for the xml format the back-end must send.
You can use the following to send a request to you're server
- Code: Select all
user.sendEventImmediate ( this.getUser ( ),"AI_COMMAND", "onRecieveXML", "ping/", "STContent="..sXml , sExml )
or use the local one if you have local stored xml that must call a method
- Code: Select all
user.sendEventImmediate ( this.getUser ( ),"AI_COMMAND", "onRecieveLocalXML", sXml)
Settings
Set the sServeradress variable or look in the init for the envoirement variable in AI_COMMAND
Example
You send een ping event to you're backend and get a pong response
--sXml
<s>ping</s>
--sExml
<cs>
<c t="sendEvent">
<p>Controller</p>
<p>onError</p>
<p>check youre internet connection</p>
</c>
</cs>
- Code: Select all
user.sendEventImmediate ( this.getUser ( ),"AI_COMMAND", "onRecieveXML", "ping/", "STContent="..sXml , sExml )
Youre backend sends the following back.
<cs>
<c t="postEvent">
<p>2</p>
<p>Controller</p>
<p>onLog</p>
<p>pong/p>
</c>
</cs>
the AI_COMMAND will call you're handler
todo
adding some data options like csv <c/>sendEvent,onLog,<c/>
to add https / http options
tips
You probelly have the logic functions of you're game, so make a handler that does the string conversion and calls that function.
Encode you're xml,
- Code: Select all
sXml = string.encodeURL( sXml )
- Attachments
-
AI_COMMAND_20120527.zip- (4.87 KiB) Downloaded 24 times
Platform: interactive visual art
Tools: polyglot-dialogue editor
Scripts: rmi xml network example, dialogue example
Tools: polyglot-dialogue editor
Scripts: rmi xml network example, dialogue example
- Cheramu
- Senior Boarder

- Posts: 58
1 post
• Page 1 of 1