overwolf.web

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

 

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": {}
    }
}

sendHttpRequest(url, method, headers, data, callback)

Version added: 0.126.0

Send an https request (of different methods) to localhost/127.0.0.1 while by-passing a valid certificate verification

  • Parameter: url <string>

  • Parameter: method <overwolf.web.enums.HttpRequestMethods>

  • Parameter: headers <overwolf.web.FetchHeader>

    an array of http headers (key,value) pairs, for example: [{ key: "Content-Type", value: "application/json" }]. Read more about http headers here.

  • Parameter: data <string> — Optional

    The data being sent to the server (relevant for POST/PUT requests).

  • Parameter: callback <function>

createWebSocket(connectionParams, callback)

Version added: 0.129

Creates a WebSocket client to localhost 127.0.0.1.   The WebSocket object is of type overwolf.web.websocket.

This call returns an object with three fields: a status string, an error string, and a WebSocket object.

  • Parameter: connectionParams <overwolf.web.WebSockcetConnectionParams>

    connection params.

    An example:

    {
          secured:true,
          port: int,
          credentials: {
            username: "riot",
            password:  string (e.g lcuCredentialsoverw.native_token)
          },
          protocols:["wamp"]
    }
    
  • Parameter: callback <function>

Callback argument:
 {
     status: |"success", "error"|,
     error: |string (on "error"),
     client: | IOverwolfWebSocket (on "success")
    }

Types

overwolf.web.WebSockcetConnectionParams

Options

secured

<bool>

port

<int>

credentials

<LoginCredentials>

protocols

<string[]>

overwolf.web.enums.HttpRequestMethods

Options

GET

POST

PUT

DELETE

overwolf.web.FetchHeader

Properties

key

Version added: 0.126.0

Type: string

value

Version added: 0.126.0

Type: string