seishun / node-steam-resources

Steam resources for Node.js
MIT License
24 stars 30 forks source link

node-steam-resources

This is a node wrapper around Steam resources (Protobufs and SteamLanguage). It's primarily intended for node-steam extension module authors.

Installation

  1. Run npm install seishun/node-steam-resources. It fetches the Steam resources and requires svn.
  2. If you're going to publish your module, add steam-resources to bundledDependencies in your package.json, since you want to publish with the resources bundled. Note that npm publish will bundle the dependencies of steam-resources as well.

If you ever need to update the resources, just run npm install seishun/node-steam-resources again.

Usage

var Steam = require('steam-resources');

Steam is now a namespace object containing enums and classes generated from the protobufs and SteamLanguage.

Enums

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.

Protobufs

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.

Structs

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:

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);