This repository was archived by the owner on Mar 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathindex.js
More file actions
55 lines (39 loc) · 1.27 KB
/
Copy pathindex.js
File metadata and controls
55 lines (39 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var EventEmitter = require('events').EventEmitter;
var Steam = require('../../steam_client');
var EMsg = Steam.EMsg;
var schema = Steam.Internal;
function SteamRichPresence(steamClient, appid) {
this._client = steamClient;
this._appid = appid;
this._client.on('message', function(header, body, callback) {
if (header.msg in handlers)
handlers[header.msg].call(this, header, body, callback);
}.bind(this));
}
require('util').inherits(SteamRichPresence, EventEmitter);
// Methods
SteamRichPresence.prototype.upload = function(body) {
this._client.send({
msg: EMsg.ClientRichPresenceUpload,
proto: {
routing_appid: this._appid
}
}, new schema.CMsgClientRichPresenceUpload(body).toBuffer());
};
SteamRichPresence.prototype.request = function(body) {
this._client.send({
msg: EMsg.ClientRichPresenceRequest,
proto: {
routing_appid: this._appid
}
}, new schema.CMsgClientRichPresenceRequest(body).toBuffer());
};
// Handlers
var handlers = {};
handlers[EMsg.ClientRichPresenceInfo] = function(header, body) {
if (header.proto.routing_appid != this._appid)
return;
var info = schema.CMsgClientRichPresenceInfo.decode(body);
this.emit('info', Steam._processProto(info));
};
Steam.SteamRichPresence = SteamRichPresence;