summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Philipp15b/go-steam/protocol/gamecoordinator
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-06-22 01:00:27 +0200
committerWim <wim@42.be>2017-06-22 01:00:27 +0200
commit1f914618538920db4bfec7b106ee97038b157c9b (patch)
tree6bd0ab107fe1673dbacdf9dfd10004289cd7bfab /vendor/github.com/Philipp15b/go-steam/protocol/gamecoordinator
parent1f9874102aaca09ce5e0289beff376c307b8c57b (diff)
downloadmatterbridge-msglm-1f914618538920db4bfec7b106ee97038b157c9b.tar.gz
matterbridge-msglm-1f914618538920db4bfec7b106ee97038b157c9b.tar.bz2
matterbridge-msglm-1f914618538920db4bfec7b106ee97038b157c9b.zip
Add vendor (steam)
Diffstat (limited to 'vendor/github.com/Philipp15b/go-steam/protocol/gamecoordinator')
-rw-r--r--vendor/github.com/Philipp15b/go-steam/protocol/gamecoordinator/msg.go132
-rw-r--r--vendor/github.com/Philipp15b/go-steam/protocol/gamecoordinator/packet.go61
2 files changed, 193 insertions, 0 deletions
diff --git a/vendor/github.com/Philipp15b/go-steam/protocol/gamecoordinator/msg.go b/vendor/github.com/Philipp15b/go-steam/protocol/gamecoordinator/msg.go
new file mode 100644
index 00000000..f2eeb8b3
--- /dev/null
+++ b/vendor/github.com/Philipp15b/go-steam/protocol/gamecoordinator/msg.go
@@ -0,0 +1,132 @@
+package gamecoordinator
+
+import (
+ "io"
+
+ . "github.com/Philipp15b/go-steam/protocol"
+ . "github.com/Philipp15b/go-steam/protocol/steamlang"
+ "github.com/golang/protobuf/proto"
+)
+
+// An outgoing message to the Game Coordinator.
+type IGCMsg interface {
+ Serializer
+ IsProto() bool
+ GetAppId() uint32
+ GetMsgType() uint32
+
+ GetTargetJobId() JobId
+ SetTargetJobId(JobId)
+ GetSourceJobId() JobId
+ SetSourceJobId(JobId)
+}
+
+type GCMsgProtobuf struct {
+ AppId uint32
+ Header *MsgGCHdrProtoBuf
+ Body proto.Message
+}
+
+func NewGCMsgProtobuf(appId, msgType uint32, body proto.Message) *GCMsgProtobuf {
+ hdr := NewMsgGCHdrProtoBuf()
+ hdr.Msg = msgType
+ return &GCMsgProtobuf{
+ AppId: appId,
+ Header: hdr,
+ Body: body,
+ }
+}
+
+func (g *GCMsgProtobuf) IsProto() bool {
+ return true
+}
+
+func (g *GCMsgProtobuf) GetAppId() uint32 {
+ return g.AppId
+}
+
+func (g *GCMsgProtobuf) GetMsgType() uint32 {
+ return g.Header.Msg
+}
+
+func (g *GCMsgProtobuf) GetTargetJobId() JobId {
+ return JobId(g.Header.Proto.GetJobidTarget())
+}
+
+func (g *GCMsgProtobuf) SetTargetJobId(job JobId) {
+ g.Header.Proto.JobidTarget = proto.Uint64(uint64(job))
+}
+
+func (g *GCMsgProtobuf) GetSourceJobId() JobId {
+ return JobId(g.Header.Proto.GetJobidSource())
+}
+
+func (g *GCMsgProtobuf) SetSourceJobId(job JobId) {
+ g.Header.Proto.JobidSource = proto.Uint64(uint64(job))
+}
+
+func (g *GCMsgProtobuf) Serialize(w io.Writer) error {
+ err := g.Header.Serialize(w)
+ if err != nil {
+ return err
+ }
+ body, err := proto.Marshal(g.Body)
+ if err != nil {
+ return err
+ }
+ _, err = w.Write(body)
+ return err
+}
+
+type GCMsg struct {
+ AppId uint32
+ MsgType uint32
+ Header *MsgGCHdr
+ Body Serializer
+}
+
+func NewGCMsg(appId, msgType uint32, body Serializer) *GCMsg {
+ return &GCMsg{
+ AppId: appId,
+ MsgType: msgType,
+ Header: NewMsgGCHdr(),
+ Body: body,
+ }
+}
+
+func (g *GCMsg) GetMsgType() uint32 {
+ return g.MsgType
+}
+
+func (g *GCMsg) GetAppId() uint32 {
+ return g.AppId
+}
+
+func (g *GCMsg) IsProto() bool {
+ return false
+}
+
+func (g *GCMsg) GetTargetJobId() JobId {
+ return JobId(g.Header.TargetJobID)
+}
+
+func (g *GCMsg) SetTargetJobId(job JobId) {
+ g.Header.TargetJobID = uint64(job)
+}
+
+func (g *GCMsg) GetSourceJobId() JobId {
+ return JobId(g.Header.SourceJobID)
+}
+
+func (g *GCMsg) SetSourceJobId(job JobId) {
+ g.Header.SourceJobID = uint64(job)
+}
+
+func (g *GCMsg) Serialize(w io.Writer) error {
+ err := g.Header.Serialize(w)
+ if err != nil {
+ return err
+ }
+ err = g.Body.Serialize(w)
+ return err
+}
diff --git a/vendor/github.com/Philipp15b/go-steam/protocol/gamecoordinator/packet.go b/vendor/github.com/Philipp15b/go-steam/protocol/gamecoordinator/packet.go
new file mode 100644
index 00000000..260e1201
--- /dev/null
+++ b/vendor/github.com/Philipp15b/go-steam/protocol/gamecoordinator/packet.go
@@ -0,0 +1,61 @@
+package gamecoordinator
+
+import (
+ "bytes"
+ . "github.com/Philipp15b/go-steam/protocol"
+ . "github.com/Philipp15b/go-steam/protocol/protobuf"
+ . "github.com/Philipp15b/go-steam/protocol/steamlang"
+ "github.com/golang/protobuf/proto"
+)
+
+// An incoming, partially unread message from the Game Coordinator.
+type GCPacket struct {
+ AppId uint32
+ MsgType uint32
+ IsProto bool
+ GCName string
+ Body []byte
+ TargetJobId JobId
+}
+
+func NewGCPacket(wrapper *CMsgGCClient) (*GCPacket, error) {
+ packet := &GCPacket{
+ AppId: wrapper.GetAppid(),
+ MsgType: wrapper.GetMsgtype(),
+ GCName: wrapper.GetGcname(),
+ }
+
+ r := bytes.NewReader(wrapper.GetPayload())
+ if IsProto(wrapper.GetMsgtype()) {
+ packet.MsgType = packet.MsgType & EMsgMask
+ packet.IsProto = true
+
+ header := NewMsgGCHdrProtoBuf()
+ err := header.Deserialize(r)
+ if err != nil {
+ return nil, err
+ }
+ packet.TargetJobId = JobId(header.Proto.GetJobidTarget())
+ } else {
+ header := NewMsgGCHdr()
+ err := header.Deserialize(r)
+ if err != nil {
+ return nil, err
+ }
+ packet.TargetJobId = JobId(header.TargetJobID)
+ }
+
+ body := make([]byte, r.Len())
+ r.Read(body)
+ packet.Body = body
+
+ return packet, nil
+}
+
+func (g *GCPacket) ReadProtoMsg(body proto.Message) {
+ proto.Unmarshal(g.Body, body)
+}
+
+func (g *GCPacket) ReadMsg(body MessageBody) {
+ body.Deserialize(bytes.NewReader(g.Body))
+}