I have a sever socket in actionscript and client socket in java.I can send a string from java to actionscript but i cannot send an object through socket.I tried to use objectOutputstream and ObjectInputStream in java but while running it is throwing exceptions like invalid stream header.Is there any way to exchange objects between java client socket and ActionScript server socket.if yes pls tell me how?
-
Is using JSON a possibility?WORMSS– WORMSS2014-04-07 12:38:41 +00:00Commented Apr 7, 2014 at 12:38
-
i tried to write a map.but i didn't find any class to write object.when i tried with ObjectOutputstream its throwing exceptions as i mentioned in questionAmar546– Amar5462014-04-07 12:42:40 +00:00Commented Apr 7, 2014 at 12:42
Add a comment
|
1 Answer
AMF - there is a built in (de)serializator and works like a charm. Efficient and fast. Check it out.
5 Comments
divillysausages
To expand on this a bit; you're looking to add BlazeDS to your java client: sourceforge.net/adobe/blazeds/wiki/Home - it lets you send AS/Java objects back and forth; you only need to remember to call
registerClassAlias on the AS sizeAmar546
@divillysausages I am not using any Web server to use BlazeDs the java program is a general java class.To use BlazeDs i've to use a web server haven't i? If i'm wrong plz correct me. If i'm correct tell me other way to send object from java program to actionscript program.
divillysausages
@Amar546 You should just be able to include BlazeDS as a lib, kind of like including a SWC in your flash code. When you talk about a web server, that's what your java client is (though technically it's a socket server :)). You could roll your own, but it's easier to use what exists already
divillysausages
@Amar546 Other than that, there's nothing special about sending objects from client to server and vice versa; BlazeDS just automates all the serialisation etc. You can use JSON/XML/your own custom format, you'll just need to write the converters on both ends. All you need to be able to do is to know what class to create on either end, and fill in the properties passed. Your not passing "objects", you're passing Byte/String representations of objects, which are then recreated on either end
Andrey Popov
If I understand right - divillysausages is providing you with some kind of (de)serializer for Java, as Flash has one built in. I'm not good in Java, but as far as I know, BlazeDS is a common solution for that. Give it a try with AMF and you will be amazed how powerful and fast it is (check out online benchmarks).