Binary WebSockets Messaging with Hessian
From Resin 4.0 Wiki
(Difference between revisions)
Ferg (Talk | contribs)
(Created page with "{{Messaging}} {{Cookbook}} === HessianEchoListener implements WebSocketListener === import com.caucho.websocket.*; import com.caucho.hessian.io.*; public class HessianEc...")
Newer edit →
(Created page with "{{Messaging}} {{Cookbook}} === HessianEchoListener implements WebSocketListener === import com.caucho.websocket.*; import com.caucho.hessian.io.*; public class HessianEc...")
Newer edit →
Revision as of 00:00, 13 January 2012
HessianEchoListener implements WebSocketListener
import com.caucho.websocket.*; import com.caucho.hessian.io.*; public class HessianEchoListener extends AbstractWebSocketListener { Hessian2Input _hIn; Hessian2Output _hOut; HessianEchoListener(HessianFactory factory) { _hIn = factory.createHessian2Input(null); _hOut = factory.createHessian2Output(null); } @Override public void onReadBinary(WebSocketContext context, InputStream is) throws IOException { _hIn.initPacket(is); Object obj = _hIn.readObject(); OutputStream os = context.beginBinaryMessage(); _hOut.initPacket(os); _hOut.writeObject(obj); _hOut.close(); } }