overwolf.web

Use the overwolf.web API to open a local HTTP web-server.

 

Here you can see a sample code for using the overwolf.web and overwolf.web.webserver APIs:

let _port = 61234;

overwolf.web.createServer(_port, serverInfo => {
    if (serverInfo.status == "error") {
        console.log("Failed to create server");
        return;
    } else {
        _server = serverInfo.server;
        // it is always good practice to removeListener before adding it
        _server.onRequest.removeListener(onRequest);
        _server.onRequest.addListener(onRequest);

        _server.listen(info => {
            console.log("Server listening status on port " + _port + " : " + info);
            //info = { "status": "success", "url": "http://localhost:61234/"}
        });
    }
});

function onRequest(info) {
    console.log(info.content);
    // info = { "content": "{'hello': 'world'}", "contentType": "application/json", "url": "http://localhost:59873/"}
}

...

_server.close();

Methods

createServer(port, callback)

Version added: 0.93.1

Creates a web server. This call returns an object with two fields: A status string and a server object. The server object is of type overwolf.web.webserver.
  • Parameter: port <int>

    The port to use.

  • Parameter: callback <function>

Callback argument:
{
    "status": "success",
    "server": {
        "onRequest": {}
    }
}