Class WebSocketServerHelper
- java.lang.Object
-
- ptolemy.actor.lib.jjs.HelperBase
-
- ptolemy.actor.lib.jjs.VertxHelperBase
-
- ptolemy.actor.lib.jjs.modules.webSocket.WebSocketServerHelper
-
public class WebSocketServerHelper extends VertxHelperBase
A helper class for the webSocketServer and browser modules' Server object in JavaScript. Instances of this class are helpers for a server that can support multiple sockets and also responds to HTTP GET and POST requests. See the documentation of those modules for instructions. This uses Vert.x for the implementation.- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Hokeun Kim and Edward A. Lee
- See Also:
WebSocketHelper
- Pt.AcceptedRating:
- Red (bilung)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.actor.lib.jjs.VertxHelperBase
VertxHelperBase.AccessorVerticle
-
Nested classes/interfaces inherited from class ptolemy.actor.lib.jjs.HelperBase
HelperBase.DATA_TYPE
-
-
Field Summary
-
Fields inherited from class ptolemy.actor.lib.jjs.VertxHelperBase
_verticle, _vertx
-
Fields inherited from class ptolemy.actor.lib.jjs.HelperBase
_actor, _currentObj
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addResource(java.lang.String path, java.lang.Object resource, java.lang.String contentType)
Add a resource to be served by the server.void
closeServer()
Close the web socket server.static WebSocketServerHelper
createServer(java.lang.Object actor, jdk.nashorn.api.scripting.ScriptObjectMirror currentObj, java.lang.String hostInterface, boolean sslTls, java.lang.String pfxKeyCertPassword, java.lang.String pfxKeyCertPath, int port, java.lang.String receiveType, java.lang.String sendType)
Create a WebSocketServerHelper instance to help a JavaScript Server instance.void
setResponse(java.lang.String response)
Set the response.void
startServer()
Create and start the server and beginning listening for connections.-
Methods inherited from class ptolemy.actor.lib.jjs.VertxHelperBase
_issueOrDeferResponse, _processPendingJob, _setBusy, closeVertx, getHelper, getImageTypes, reset, submit, supportedReceiveTypes, supportedSendTypes, undeploy
-
Methods inherited from class ptolemy.actor.lib.jjs.HelperBase
_appendNumericToBuffer, _appendToBuffer, _error, _error, _error, _error, _extractFromBuffer, _issueResponse, _removeDuplicates, _sizeOfType, _toJavaBytes, _toJSArray, getHelping
-
-
-
-
Method Detail
-
addResource
public void addResource(java.lang.String path, java.lang.Object resource, java.lang.String contentType)
Add a resource to be served by the server.- Parameters:
path
- The path to the resource.resource
- The resource to serve upon a request for this path.contentType
- The content type.
-
closeServer
public void closeServer()
Close the web socket server. Note that this closing happens asynchronously. The server may not be closed when this returns.
-
createServer
public static WebSocketServerHelper createServer(java.lang.Object actor, jdk.nashorn.api.scripting.ScriptObjectMirror currentObj, java.lang.String hostInterface, boolean sslTls, java.lang.String pfxKeyCertPassword, java.lang.String pfxKeyCertPath, int port, java.lang.String receiveType, java.lang.String sendType)
Create a WebSocketServerHelper instance to help a JavaScript Server instance.- Parameters:
actor
- The actor associated with this helper.currentObj
- The JavaScript Server instance for which this is a helper.hostInterface
- The host interface to use, in case there the host has more than one interface (e.g. Ethernet and WiFi). This is IP address or name, and if the argument is null, then "localhost" will be used.sslTls
- Whether SSL/TLS is enabled. This defaults to false.port
- The port number that the server will use.pfxKeyCertPassword
- The password to open the file specified in pfxKeyCertPath.pfxKeyCertPath
- The path of the file that stores the private key and certificate in PFX (PKCS#12) format for the server.receiveType
- The type to assume for incoming messages.sendType
- The type for outgoing messages.- Returns:
- A new WebSocketServerHelper instance.
-
setResponse
public void setResponse(java.lang.String response)
Set the response.- Parameters:
response
- The response.
-
startServer
public void startServer()
Create and start the server and beginning listening for connections. When a new connection request is received and a socket has been opened, emit the 'connection' event with the socket as an argument.
-
-