Class HttpServerHelper
- java.lang.Object
-
- ptolemy.actor.lib.jjs.HelperBase
-
- ptolemy.actor.lib.jjs.VertxHelperBase
-
- ptolemy.actor.lib.jjs.modules.httpServer.HttpServerHelper
-
public class HttpServerHelper extends VertxHelperBase
A helper class for the httpSocket module's Server object in JavaScript. Instances of this class are helpers for a server that can support multiple sockets. See the documentation of that module for instructions. This uses Vert.x for the implementation.- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Edward A. Lee amd Elizabeth Osyk
- 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
closeServer()
Close the web socket server.AWTImageToken
convertImageBody(java.lang.String body)
Convert a string to an image token.static HttpServerHelper
getOrCreateServer(java.lang.Object actor, jdk.nashorn.api.scripting.ScriptObjectMirror currentObj, java.lang.String hostInterface, int port)
Create a HttpServerHelper instance to help a JavaScript HttpServer instance.void
respond(int requestID, java.lang.String responseText, int responseCode)
Respond to the request with the specified ID by sending the specified text.void
startServer()
Create and start the server and beginning listening for requests.-
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
-
closeServer
public void closeServer()
Close the web socket server. Note that this closing happens asynchronously. The server may not be closed when this returns.
-
convertImageBody
public AWTImageToken convertImageBody(java.lang.String body)
Convert a string to an image token. If there is a problem then _error() is called.- Parameters:
body
- The html to be converted.- Returns:
- The ImageToken that is created.
-
getOrCreateServer
public static HttpServerHelper getOrCreateServer(java.lang.Object actor, jdk.nashorn.api.scripting.ScriptObjectMirror currentObj, java.lang.String hostInterface, int port)
Create a HttpServerHelper instance to help a JavaScript HttpServer instance.- Parameters:
actor
- The actor associated with this helper.currentObj
- The JavaScript HttpServer 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.port
- The port number that the server will use.- Returns:
- A new HttpServerHelper instance.
-
respond
public void respond(int requestID, java.lang.String responseText, int responseCode)
Respond to the request with the specified ID by sending the specified text.- Parameters:
requestID
- The request ID.responseText
- The text with which to respond.responseCode
- The response code
-
startServer
public void startServer()
Create and start the server and beginning listening for requests. When a new request is received, call the _request() function of the associated JavaScript HttpServer object.
-
-