Class SocketHelper.SocketWrapper
- java.lang.Object
-
- ptolemy.actor.lib.jjs.modules.socket.SocketHelper.SocketWrapper
-
- Enclosing class:
- SocketHelper
public class SocketHelper.SocketWrapper extends java.lang.Object
Wrapper for connected TCP sockets. An instance of this class handles socket events from the Vert.x NetSocket object and translates them into JavaScript events emitted by the eventEmitter specified in the constructor. The events emitted are:- close: Emitted when the socket closes. It has no arguments.
- error: Emitted when an error occurs. It is passed an error message.
- data: Emitted when the socket received data. It is passed the data.
-
-
Constructor Summary
Constructors Constructor Description SocketWrapper(jdk.nashorn.api.scripting.ScriptObjectMirror eventEmitter, java.lang.Object socket, java.lang.String sendType, java.lang.String receiveType, boolean rawBytes, boolean emitBatchDataAsAvailable)
Construct a handler for connections established.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the socket and remove all event listeners on the associated event emitter.void
send(java.lang.Object data)
Send data over the socket.
-
-
-
Constructor Detail
-
SocketWrapper
public SocketWrapper(jdk.nashorn.api.scripting.ScriptObjectMirror eventEmitter, java.lang.Object socket, java.lang.String sendType, java.lang.String receiveType, boolean rawBytes, boolean emitBatchDataAsAvailable)
Construct a handler for connections established. This constructor must be called in the verticle thread, not in the director thread.- Parameters:
eventEmitter
- The JavaScript object that will emit socket events.socket
- The Vertx socket object.sendType
- The send type.receiveType
- The receive type.rawBytes
- If true, send and received raw bytes, with no message framing. If false, then prepend each sent item with a length, and for received items, assume received data is prepended with a length and emit received data only when a complete message has arrived.emitBatchDataAsAvailable
- Whether to emit all data available when the TCP stream is received and when rawBytes is true. This parameter is intended for socket.js module and this SocketHelper. Thus, this parameter will not be exposed to TCP socket accessors. Set this true only when the TCP stream is going to be handled by upper layer protocols to avoid non-deterministic behavior.
-
-