/
x_svc_PresenceService.go
172 lines (159 loc) · 4.84 KB
/
x_svc_PresenceService.go
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// generated by protoc-gen-gcraft : DO NOT EDIT
package bnet
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
protocol "github.com/Gophercraft/core/bnet/bgs/protocol"
v1 "github.com/Gophercraft/core/bnet/bgs/protocol/presence/v1"
math "math"
)
// shut the compiler up
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
var _ = protocol.E_MethodOptions
const PresenceServiceHash = 0xFA0796FF
type PresenceService interface {
Subscribe(*Conn, uint32, *v1.SubscribeRequest)
Unsubscribe(*Conn, uint32, *v1.UnsubscribeRequest)
Update(*Conn, uint32, *v1.UpdateRequest)
Query(*Conn, uint32, *v1.QueryRequest)
BatchSubscribe(*Conn, uint32, *v1.BatchSubscribeRequest)
BatchUnsubscribe(*Conn, uint32, *v1.BatchUnsubscribeRequest)
}
func DispatchPresenceService(conn *Conn, svc PresenceService, token uint32, method uint32, data []byte) error {
switch method {
case 1:
var args v1.SubscribeRequest
err := proto.Unmarshal(data, &args)
if err != nil {
return err
}
svc.Subscribe(conn, token, &args)
case 2:
var args v1.UnsubscribeRequest
err := proto.Unmarshal(data, &args)
if err != nil {
return err
}
svc.Unsubscribe(conn, token, &args)
case 3:
var args v1.UpdateRequest
err := proto.Unmarshal(data, &args)
if err != nil {
return err
}
svc.Update(conn, token, &args)
case 4:
var args v1.QueryRequest
err := proto.Unmarshal(data, &args)
if err != nil {
return err
}
svc.Query(conn, token, &args)
case 8:
var args v1.BatchSubscribeRequest
err := proto.Unmarshal(data, &args)
if err != nil {
return err
}
svc.BatchSubscribe(conn, token, &args)
case 9:
var args v1.BatchUnsubscribeRequest
err := proto.Unmarshal(data, &args)
if err != nil {
return err
}
svc.BatchUnsubscribe(conn, token, &args)
}
return nil
}
type EmptyPresenceService struct{}
func (e EmptyPresenceService) Subscribe(conn *Conn, token uint32, args *v1.SubscribeRequest) {
conn.SendResponseCode(token, ERROR_RPC_NOT_IMPLEMENTED)
}
func (e EmptyPresenceService) Unsubscribe(conn *Conn, token uint32, args *v1.UnsubscribeRequest) {
conn.SendResponseCode(token, ERROR_RPC_NOT_IMPLEMENTED)
}
func (e EmptyPresenceService) Update(conn *Conn, token uint32, args *v1.UpdateRequest) {
conn.SendResponseCode(token, ERROR_RPC_NOT_IMPLEMENTED)
}
func (e EmptyPresenceService) Query(conn *Conn, token uint32, args *v1.QueryRequest) {
conn.SendResponseCode(token, ERROR_RPC_NOT_IMPLEMENTED)
}
func (e EmptyPresenceService) BatchSubscribe(conn *Conn, token uint32, args *v1.BatchSubscribeRequest) {
conn.SendResponseCode(token, ERROR_RPC_NOT_IMPLEMENTED)
}
func (e EmptyPresenceService) BatchUnsubscribe(conn *Conn, token uint32, args *v1.BatchUnsubscribeRequest) {
conn.SendResponseCode(token, ERROR_RPC_NOT_IMPLEMENTED)
}
func (c *Conn) PresenceService_Request_Subscribe(args *v1.SubscribeRequest) error {
header, _, err := c.Request(PresenceServiceHash, 1, args)
if err != nil {
return err
}
if Status(header.GetStatus()) != ERROR_OK {
return fmt.Errorf("bnet: non-ok status 0x%08X", header.GetStatus())
}
return nil
}
func (c *Conn) PresenceService_Request_Unsubscribe(args *v1.UnsubscribeRequest) error {
header, _, err := c.Request(PresenceServiceHash, 2, args)
if err != nil {
return err
}
if Status(header.GetStatus()) != ERROR_OK {
return fmt.Errorf("bnet: non-ok status 0x%08X", header.GetStatus())
}
return nil
}
func (c *Conn) PresenceService_Request_Update(args *v1.UpdateRequest) error {
header, _, err := c.Request(PresenceServiceHash, 3, args)
if err != nil {
return err
}
if Status(header.GetStatus()) != ERROR_OK {
return fmt.Errorf("bnet: non-ok status 0x%08X", header.GetStatus())
}
return nil
}
func (c *Conn) PresenceService_Request_Query(args *v1.QueryRequest) (*v1.QueryResponse, error) {
header, bytes, err := c.Request(PresenceServiceHash, 4, args)
if err != nil {
return nil, err
}
if Status(header.GetStatus()) != ERROR_OK {
return nil, fmt.Errorf("bnet: non-ok status 0x%08X", header.GetStatus())
}
var out v1.QueryResponse
err = proto.Unmarshal(bytes, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func (c *Conn) PresenceService_Request_BatchSubscribe(args *v1.BatchSubscribeRequest) (*v1.BatchSubscribeResponse, error) {
header, bytes, err := c.Request(PresenceServiceHash, 8, args)
if err != nil {
return nil, err
}
if Status(header.GetStatus()) != ERROR_OK {
return nil, fmt.Errorf("bnet: non-ok status 0x%08X", header.GetStatus())
}
var out v1.BatchSubscribeResponse
err = proto.Unmarshal(bytes, &out)
if err != nil {
return nil, err
}
return &out, nil
}
func (c *Conn) PresenceService_Request_BatchUnsubscribe(args *v1.BatchUnsubscribeRequest) error {
header, _, err := c.Request(PresenceServiceHash, 9, args)
if err != nil {
return err
}
if Status(header.GetStatus()) != ERROR_OK {
return fmt.Errorf("bnet: non-ok status 0x%08X", header.GetStatus())
}
return nil
}