I don't understand how to send a java object using the message protocol passing it through a bidirectional pipe.
can someone provide sample code on how to do it, it would really help me a lot!
well unfortunately there is no direct way to pu java object in jxta message.
The way to do it is to serialize your object to byte array and then put the byte array to
Then you put your ByteArrayMessageElement to message and send it.
on the other and you must deserialize your byte array back to object and cast it to right instance.
Here are the methods for serializing and deserializing.
public static byte serializeMessage(Serializable object) throws IOException
ObjectOutputStream oos =null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
oos= new ObjectOutputStream(baos);
public static Object deSerializeMessage(bytedata) throws IOException, ClassNotFoundException
recived = new ObjectInputStream(new
as you can see object that you want to serialize must implement serialization interface.
After deserialization don't forget to cast.
hope this helps you.
Be aware that you can not exceed the MTU 64K for a JXTA message.
Yes, better use a JxtaSocket that does a lot of heavy work for you.
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Participation.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.