Default charset value.
Host name of the server.
IP address of the server.
Port listened to by the server.
The current HTTP Request Object.
The current HTTP Response Object.
SSL properties of the server.
Return true if the HTTP Server is started.
Adds a request handler function on the server.
It is recommended to declare all request handler in the bootstrap.js
file in order to be available at server start up.
// It is recommended to write these lines in bootstrap.js
// On every "/ping" requests, call "pong()" function in "request-greetings" module
httpServer.addRequestHandler('^/ping$', 'request-greetings', 'pong');
// modules/request-greetings/index.js
exports.pong = function pong( request, response ){
return 'pong';
}
Regexp pattern to intercept a HTTP request
Path to the module that exports the functionName
Function name which handles the request and returns the request response
Adds a WebSocket handler script on the server.
It is recommended to declare all websocket handler in the bootstrap.js
file in order to be available at server start up.
// It is recommended to write these lines in bootstrap.js
httpServer.addWebSocketHandler('^/ping$', './websocket-greetings.js', 'websocket-id', true);
// ./websocket-greetings.js
// Same as for ShareWorker
// Called every time a new websocket is connected
onconnect = function ( event ) {
// Get the websocket port
var wsPort = event.ports[0];
// Get the websocket handshake data
var client = event.client;
// Is available: client.ip, client.port, client.urlPath, client.headers
// Called every time a client sends a message
wsPort.onmessage = function( message ) {
// Process data send by the client
if ( message.data == 'hello' ){
console.log( 'websocket data received: '+ message.data );
// Send a response to client
wsPort.postMessage( 'Hello back !' );
}else{
console.log( 'websocket data skipped: '+ JSON.stringify(message) );
}
};
// Called when the socket receives an error
wsPort.onerror = function() {
// Handle websocket errors
};
// Called when the socket is closed
wsPort.onclose = function() {
// Do nothing and wait for another websocket connection
};
};
Regexp pattern to intercept a WS request
Absolute or relative path from the project to the file that defines the websocket handler. Filesystem are not working in filePath parameter (PROJECT
, SOLUTION
, ...).
Socket ID usefull for removeWebSocketHandler()
true
if uses shared worker (recommended). false
if uses dedicated worker.
Removes an existing request handler function on the server.
// Must match parameters of "addRequestHandler()"
// httpServer.addRequestHandler('^/ping$', 'request-greetings', 'pong');
httpServer.removeRequestHandler('^/ping$', 'request-greetings', 'pong');
Regexp pattern to intercept a HTTP request
Path to the module that exports the functionName
Function name which handles the request
Removes an existing websocket handler on the server.
// Must match socketID parameter of "addWebSocketHandler()"
// httpServer.addWebSocketHandler('^/ping$', 'backend/websocket-greetings.js', 'websocket-id', true);
httpServer.removeWebSocketHandler( 'websocket-id' );
Identifies the websocket to remove
Starts the Wakanda HTTP server.
Stops the Wakanda HTTP server.
Cache properties of the HTTP server.