Private IDCounterStarts at 0 and is incremented with each request sent to StarCraft 2.
Private Readonly connectingA DeferredTask object is used to detect when the WebSocket connection has successfully
connected.
Private lastThe status of StarCraft 2 is returned with each API response object and we record it. This is useful so that end-users can query for what the current status of StarCraft 2 is.
For example, they might want to skip creating a game if a game is already created.
Private Readonly requestFor each request sent over the wire, we keep track of it with a promise. The resolver function of the promise is fired when the response is received.
The keys of the map are equal to the ID of the request that was sent. (The response will have a matching ID.)
After the response is received and the resolver is retrieved/fired, the resolver is removed from the map.
Private Readonly verbosePrivate wsThe "ws" library is used to handle the underlying WebSocket connection to StarCraft 2.
Connects to StarCraft 2 via a WebSocket connection.
You must use this method before using any of the other methods on this class.
Optional. If not specified, 127.0.0.1 will be used.
Optional. If not specified, 5000 will be used.
The current status of StarCraft 2 (e.g. whether it is in a game, in a replay, etc.).
Private sendTell StarCraft 2 to advance the game. By default, this will only advance one step.
Generated using TypeDoc
Communication is performed with StarCraft 2 through a WebSocket connection. A
Requestobject is sent to the game, and it returns aResponseobject.For more information, see: https://github.com/Blizzard/s2client-proto/blob/master/docs/protocol.md
This class provides methods for each type of request. For example, to send a "ping" request, you invoke the
pingmethod.Before using this class, you must connect to the game with the
connectmethod.