-
-
Notifications
You must be signed in to change notification settings - Fork 158
Game Coordinator
Alex Corn edited this page Feb 5, 2019
·
3 revisions
v4.1.0 or later is required to interact with a GC.
Interacting with a GC typically goes like this:
- Listen for the
appLaunched
event. It will be emitted with a singleappId
property. - Talk to the GC using
sendToGC
- Receive messages from the GC using
receivedFromGC
- Listen for the
appQuit
event. It will be emitted with a singleappId
property ifgamesPlayed
is called and the given app ID is not included (but it was in the previousgamesPlayed
call).-
appQuit
will not be emitted if the client disconnects from Steam. Also listen fordisconnected
anderror
events.
-
These methods and events are available on a SteamUser
object. For example:
const SteamUser = require('steam-user');
let user = new SteamUser();
user.logOn(...);
user.on('loggedOn', () => {
user.gamesPlayed([440]);
});
user.on('appLaunched', (appid) => {
// 4006 = ClientHello in TF2
user.sendToGC(appid, 4006, {}, Buffer.alloc(0));
});
user.on('receivedFromGC', (appid, msgType, payload) => {
console.log(`Received message ${msgType} from GC ${appid} with ${payload.length} bytes`);
});
-
appid
- The AppID of the game to which you want to send this GC message -
msgType
- The GC-specific msg ID for this message (without any protobuf masking) -
protoBufHeader
- If this is a protobuf-based message, this needs to be the protobuf header for this message. If you don't need any custom header fields (you almost definitely don't), pass an empty object here ({}
). Otherwise, if this is not a protobuf-based message, passnull
. -
payload
- The payload for this message, either a serialized protobuf message or a stream of bytes. Either way, it should be aBuffer
(or aByteBuffer
). -
callback
- Optional. If this is a job-based message, pass a callback here and it will be invoked when a response is available.-
appid
- The AppID of the GC this response came from -
msgType
- The GC-specific msg ID for this response (without any protobuf masking) -
payload
- The payload of this response, as aBuffer
-
Send a message to a GC.
appid
Emitted when gamesPlayed
is called with a Steam AppID, indicating that you are now "playing" this game.
appid
Emitted when gamesPlayed
is called without a Steam AppID that was present in the previous invocation of appQuit
.
Note: This will not be emitted if the client disconnects from Steam. If you want to know if an app is no longer being "played", you should also listen for disconnected
and error
events.
-
appid
- The AppID of the GC this message came from -
msgType
- The GC-specific msg ID for this message (without any protobuf masking) -
payload
- The payload for this message, as aBuffer
Emitted when a message is received from a GC but not as a job response (i.e. a callback to sendToGC
).