jWebSocket Forum

[Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
put Object or ArrayList into a Token  XML
Forum Index » Communication Models, Events, Channels, Tokens
Author Message
dromani

jWebSocket Forum Fan
[Avatar]

Joined: 14/02/2011 19:00:26
Messages: 72
Location: Spain
Offline

Very usefull, but I think that it would be better if all classes have their own documentation (javadoc).
[WWW] [MSN]
aschulze

jWebSocket Owner
[Avatar]

Joined: 16/03/2010 18:15:55
Messages: 375
Location: Germany, Herzogenrath
Offline

Hi dromani,

you can put objects into a token as well as a list of objects, given that the objects are "tokenizable".
Each object can be serialized into a token by implementing the Tokenizable interface for that object.
And then you can use the putToken method to add the tokenized object into your token.
The same goes for lists of objects. You can create a list, add tokenized objects to that list and add the list to the token via the putList Method.
That easy! If lists are empty the JSON object contains an empty array - no problem. If a value null, a null value is passed - no problem as well.

Best Regards
Alex
[WWW]
jense

jWebSocket Forum User

Joined: 05/12/2011 11:06:55
Messages: 2
Offline

Hallo,

I am wondering why there is no way to just serialize Objects recursively without need to manually implement ITokenizable?

E.g. com.google.gson does a well job here...

Also, I am wondering why RPC-Objects must implement RPCCallable?

These dependencies and manual implementations make the usage very hard and not suitable in existing settings.

Thanks
Jens


Quentin

jWebSocket Forum User

Joined: 22/07/2010 00:01:01
Messages: 37
Location: Paris, France
Offline

The idea with ITokenizable was to allow communication with different formats (not only json, but xml, google protobuff or whatever)
The idea behind RPCCallable was to let jwebsocket handle the life cylce of your rpc objects for you.
You should extend objects such as BaseRPCCallable or the other implementation which is connector-scoped.
But you're right, it might not be the best solution, and adding an annotation on the class instead of the "extends thing" is probably a better idea.
Some extra help here :
http://avricot.com/blog/public/jwebsocket/rrpc_article/android%20jwebsocket.html
[WWW]
jense

jWebSocket Forum User

Joined: 05/12/2011 11:06:55
Messages: 2
Offline

Thanks for your answer, Quentin. We already use many classes for messaging and RPC without any dependency on a framework on these basic classes. We can use jWebsocket as an additional alternative only, if we don't need to touch all these message and RPC classes, even no annotation. To handle the life cylce of RPC objects, you only need an empty constructor.
Quentin

jWebSocket Forum User

Joined: 22/07/2010 00:01:01
Messages: 37
Location: Paris, France
Offline

Take a look at the BaseConnectorRPCCallable class, the interface allow us to create a unique rpc-instance for each client, that's why I add this interface. http://code.google.com/p/jwebsocket/source/browse/branches/jWebSocket-1.0/jWebSocketPlugIns/jWebSocketRPCPlugIn/src/main/java/org/jwebsocket/plugins/rpc/BaseConnectorRPCCallable.java?r=1758

But it's not a big deal to patch the rpc plugin, you have to change the initRPCCallableClass method and the way you get the instance once it's loaded :
line 305
RPCCallable lInstance = lInstanceGenerator.getInstance(aConnector);
http://code.google.com/p/jwebsocket/source/browse/branches/jWebSocket-1.0/jWebSocketPlugIns/jWebSocketRPCPlugIn/src/main/java/org/jwebsocket/plugins/rpc/RPCPlugIn.java?r=1758

Hope this helps
[WWW]
Jerry

jWebSocket Forum Fan

Joined: 05/08/2011 09:49:30
Messages: 59
Offline

Hi,

Is there any change in the lastest version ?and how to resolve above issue , I have simular question as well .

Right now my way to resolve this issue, I do not implement the ITokenizable interface. I just use use Json lib to convert my whole object into string and then put my object string into token object by using setstring();

Thanks
Jerry
kate321

jWebSocket Forum User
[Avatar]

Joined: 06/12/2017 10:41:30
Messages: 3
Offline

I was looking for the same problem but thanks I got the answer in comments.


Buy Fencing Direct vouchers & discount codes

[URL=http://www.hirelaptops.co.uk/ipad-hire/]iPad Hire/URL]
 
Forum Index » Communication Models, Events, Channels, Tokens
Go to:   
Powered by JForum 2.1.9 © JForum Team