The matchamker class is primarily used to find and create games.
import Matchmaker from 'yolkbot/matchmaker';
const mm = new Matchmaker();
instance: string - the instance of the game to use, default: 'shellshock.io'protocol: string - the protocol to use, default: 'wss'api: API - an API instance to use for authentication, default: nullsessionId: string - the session ID to use for the matchmaker, default: nullnoLogin: boolean - whether to skip login and just go straight to finding games (WILL BREAK MM IN MOST CASES), default: falseproxy: string - the socks5 (or socks5h) proxy to use for the matchmaker, default: null (no proxy)connectionTimeout: number - the timeout in milliseconds for connecting to the matchmaker server, default: 5000Each of these have a default value and can be passed if needed like so:
import Matchmaker from 'yolkbot/matchmaker';
const mm = new Matchmaker({
instance: 'egg.dance',
protocol: 'wss'
});
This is a method that waits for the matchmaker to connect. It returns a promise that resolves when the matchmaker is connected.
const mm = new Matchmaker();
await mm.waitForConnect();
console.log('matchmaker connected!');
If the matchmaker is already connected, this will resolve immediately.
This method returns a list of regions that the matchmaker supports. It returns an array of region objects, each containing id (the unstyled name) and sub (region subdomain) properties.
const regions = await mm.getRegions();
console.log(regions);
You can "ping" each region by opening a WebSocket connection to its sub and measuring the time it takes to connect.
This closes the connection to the matchmaker.
This sends a raw message to the matchmaker. It is automatically stringified, so you can pass an object directly.
mm.send({
command: 'joinGame',
id: 'game-code-here',
observe: false,
sessionId: mm.sessionId
});
The matchmaker has on, once, and off methods for listening to various events. Currently, the only events are error, authFail (from the API), and msg (a message from the matchmaker).
The matchamker class is primarily used to find and create games.
import Matchmaker from 'yolkbot/matchmaker';
const mm = new Matchmaker();
instance: string - the instance of the game to use, default: 'shellshock.io'protocol: string - the protocol to use, default: 'wss'api: API - an API instance to use for authentication, default: nullsessionId: string - the session ID to use for the matchmaker, default: nullnoLogin: boolean - whether to skip login and just go straight to finding games (WILL BREAK MM IN MOST CASES), default: falseproxy: string - the socks5 (or socks5h) proxy to use for the matchmaker, default: null (no proxy)connectionTimeout: number - the timeout in milliseconds for connecting to the matchmaker server, default: 5000Each of these have a default value and can be passed if needed like so:
import Matchmaker from 'yolkbot/matchmaker';
const mm = new Matchmaker({
instance: 'egg.dance',
protocol: 'wss'
});
This is a method that waits for the matchmaker to connect. It returns a promise that resolves when the matchmaker is connected.
const mm = new Matchmaker();
await mm.waitForConnect();
console.log('matchmaker connected!');
If the matchmaker is already connected, this will resolve immediately.
This method returns a list of regions that the matchmaker supports. It returns an array of region objects, each containing id (the unstyled name) and sub (region subdomain) properties.
const regions = await mm.getRegions();
console.log(regions);
You can "ping" each region by opening a WebSocket connection to its sub and measuring the time it takes to connect.
This closes the connection to the matchmaker.
This sends a raw message to the matchmaker. It is automatically stringified, so you can pass an object directly.
mm.send({
command: 'joinGame',
id: 'game-code-here',
observe: false,
sessionId: mm.sessionId
});
The matchmaker has on, once, and off methods for listening to various events. Currently, the only events are error, authFail (from the API), and msg (a message from the matchmaker).