This is a node wrapper around Steam resources (Protobufs and SteamLanguage) from SteamKit. It's primarily intended for node-steam extension module authors.
npm install git://github.com/seishun/node-steam-resources.git
- Run
npm install
in thesteam-resources
directory to run theprepublish
script (see npm/npm#3055). It pulls the Steam resources from SteamKit and requiressvn
. - If you're going to publish your module, add
steam-resources
tobundledDependencies
in yourpackage.json
, since you want to publish with the resources bundled. Note thatnpm publish
will bundle the dependencies ofsteam-resources
as well. You could deletesteam-resources/node_modules
manually before publishing, but npm <3 doesn't install dependencies of bundled dependencies automatically.
If you ever need to update the resources, just run npm install
in the steam-resources
directory again.
var Steam = require('steam-resources');
Steam
is now a namespace object containing enums and classes generated from the protobufs and SteamLanguage.
For each enum in SteamLanguage, there is an equivalently named property on Steam
. The property is an object; for each of the enum's members, there is an equivalently named property on the object with an equivalent Number value.
For example, Steam.EClanPermission.OwnerOfficerModerator
is equal to 11
.
For each protobuf message or enum available in SteamKit2, there is an equivalently named class or enum generated using ProtoBuf.js version ^4.1. They lie in the same hierarchy as in SteamKit2, with objects for namespaces. (If you see a mismatch, consider that a bug.)
For example, the CMsgGCTopCustomGamesList
message from dota_gcmessages_common.proto is available as SteamKit2.GC.Dota.Internal.CMsgGCTopCustomGamesList
in SteamKit2 and as Steam.GC.Dota.Internal.CMsgGCTopCustomGamesList
here.
For each class in SteamLanguage, there is an equivalently named class in Steam.Internal
. They are intended to implement a subset of the API provided by ProtoBuf.js message classes. Namely, for a class MsgGabe
:
- An
MsgGabe
instance has an equivalently named property for each non-const member ofMsgGabe
with the type as follows (modifiers likeboolmarshal
are ignored):- byte<> members: ByteBuffer.js ^5.0 objects
long
andulong
members: ByteBuffer.Long objects- Other numeric members: Number
- Protobuf message members: message class instances
- For each const member of
MsgGabe
, there is an equivalently named property on theMsgGabe
class with an equivalent value. MsgGabe.decode(buf)
returns anMsgGabe
instance deserialized frombuf
.buf
can be either a Buffer or a ByteBuffer.js ^5.0 instance. In the latter case, it decodes starting frombuf.offset
and increments it by message size.new MsgGabe(obj)
creates anMsgGabe
instance from an object.new MsgGabe()
is equivalent tonew MsgGabe({})
. For each non-const member ofMsgGabe
, if there is an equivalently named property inobj
, it sets the instance property to the (possibly converted) value of the property inobj
, otherwise to the default value. In addition to the types listed above,obj
properties can have the following types:- byte<> members: Buffer objects (converted using
ByteBuffer.wrap
) - Numeric members: String or Number (converted using
Long.fromValue
) - Protobuf message members: objects (converted using the message class constructor)
- byte<> members: Buffer objects (converted using
- An
MsgGabe
instancegabe
has the following methods:gabe.encode()
serializes theMsgGabe
instance and returns a ByteBuffer.js ^5.0 object.gabe.toBuffer()
returnsthis.encode().toBuffer()
.
For example, MsgClientChatRoomInfo
can be used as follows:
var chatRoomInfo = new Steam.Internal.MsgClientChatRoomInfo({
steamIdChat: '103582791432594962'
});
var buf = chatRoomInfo.toBuffer();
var chatRoomInfo2 = Steam.Internal.MsgClientChatRoomInfo.decode(buf);