Sending objects to players from a Java extension

Post here your suggestions for new possible features in SmartFoxServer.

Moderators: Lapo, Bax

Post Reply
Ansury
Posts: 5
Joined: 15 Sep 2007, 05:17

Sending objects to players from a Java extension

Post by Ansury »

Subject says it all - sending objects from the server itself, rather than from one player to the others. A method of doing this for specific users, and all the users in a specific room would be nice.

This doesn't seem possible right now, unless I've missed it in the API somewhere.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

It is definitely possible.
You can use both XML (using ActionscriptObject class) and JSON format (using org.json.JSONObject)

JSON is probably best as it additionally saves bandwidth when compared to XML. All you have to do is create the object from your extension and send it to the user(s). The client will receive it in native format, ready for use. Very simple ;)

More info about JSON:
http://www.json.org/
http://www.json.org/javadoc/index.html? ... bject.html

More info about ActionscriptObject:
http://www.smartfoxserver.com/docs/docP ... bject.html

Additionally check the java source examples provided in the javaExtensions/ folder

HTH
Lapo
--
gotoAndPlay()
...addicted to flash games
Ansury
Posts: 5
Joined: 15 Sep 2007, 05:17

Post by Ansury »

Cool, I'll look for the examples, thanks alot!
Post Reply