Example of use (WebSocket communication)

This is a simple example to exaplin how to implement using the WebSocket communication method. This example is implemented in JavaScript and can be modified and used according to the user’s environment.

WebSocket communication function is supported in version 1.1.0.30 or higher.

The WebSocket communication method is supported in an environment where HTTPS communication cannot be used. This is a supplementary measure for blocking local network access during HTTP communication in Chrome and Edge browsers.

Request new id

Fill in the platform and action element values and request a new id.

function tpl_WebSocketConnect() {
	tpl_ConnectData();

	var path = "ws://127.0.0.1:7970/launcher/nexacro/"+new Date().getTime();
	objWebSocket = new WebSocket(path);

	objWebSocket.onopen = function (evt) { onOpen(evt) };
	objWebSocket.onclose = function (evt) { onClose(evt) };
	objWebSocket.onmessage = function (evt) { onMessage(evt) };
	objWebSocket.onerror = function (evt) { onError(evt) };
}

function tpl_ConnectData() {
	objNexacro.platform = 'nexacro';
	objNexacro.action = 'create';
}

function onOpen(evt) {
	sendData(true);
}

function onMessage(evt) {
	var data = evt.data;
	console.log(data);
}

The requested jsonDate items are as follows. Only the element entries are filled and sent.

{"platform":"nexacro","action":"create"}

The launcher service receives the request and assigns an id to it and returns it. The id and result items are checked. The id value will be used in subsequent requests.

{"action":"create","id":"1522821857","platform":"nexacro","result":"success"}

Setup and running

The way to set required properties and execute methods is the same as for HTTP communication. Refer to the contents below.

Required Property Setting
Method Execution

Full code

The use example code can be downloaded from the following URL.

Full code