This repository has been archived by the owner on Jan 17, 2023. It is now read-only.
/
x_svc_FriendsListener.go
184 lines (170 loc) · 5.7 KB
/
x_svc_FriendsListener.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
173
174
175
176
177
178
179
180
181
182
183
184
// generated by protoc-gen-gcraft : DO NOT EDIT
package bnet
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
protocol "github.com/superp00t/gophercraft/bnet/bgs/protocol"
v1 "github.com/superp00t/gophercraft/bnet/bgs/protocol/friends/v1"
math "math"
)
// shut the compiler up
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
var _ = protocol.E_MethodOptions
const FriendsListenerHash = 0x6F259A13
type FriendsListener interface {
OnFriendAdded(*Conn, uint32, *v1.FriendNotification)
OnFriendRemoved(*Conn, uint32, *v1.FriendNotification)
OnReceivedInvitationAdded(*Conn, uint32, *v1.InvitationNotification)
OnReceivedInvitationRemoved(*Conn, uint32, *v1.InvitationNotification)
OnSentInvitationAdded(*Conn, uint32, *v1.SentInvitationAddedNotification)
OnSentInvitationRemoved(*Conn, uint32, *v1.SentInvitationRemovedNotification)
OnUpdateFriendState(*Conn, uint32, *v1.UpdateFriendStateNotification)
}
func DispatchFriendsListener(conn *Conn, svc FriendsListener, token uint32, method uint32, data []byte) error {
switch method {
case 1:
var args v1.FriendNotification
err := proto.Unmarshal(data, &args)
if err != nil {
return err
}
svc.OnFriendAdded(conn, token, &args)
case 2:
var args v1.FriendNotification
err := proto.Unmarshal(data, &args)
if err != nil {
return err
}
svc.OnFriendRemoved(conn, token, &args)
case 3:
var args v1.InvitationNotification
err := proto.Unmarshal(data, &args)
if err != nil {
return err
}
svc.OnReceivedInvitationAdded(conn, token, &args)
case 4:
var args v1.InvitationNotification
err := proto.Unmarshal(data, &args)
if err != nil {
return err
}
svc.OnReceivedInvitationRemoved(conn, token, &args)
case 5:
var args v1.SentInvitationAddedNotification
err := proto.Unmarshal(data, &args)
if err != nil {
return err
}
svc.OnSentInvitationAdded(conn, token, &args)
case 6:
var args v1.SentInvitationRemovedNotification
err := proto.Unmarshal(data, &args)
if err != nil {
return err
}
svc.OnSentInvitationRemoved(conn, token, &args)
case 7:
var args v1.UpdateFriendStateNotification
err := proto.Unmarshal(data, &args)
if err != nil {
return err
}
svc.OnUpdateFriendState(conn, token, &args)
}
return nil
}
type EmptyFriendsListener struct{}
func (e EmptyFriendsListener) OnFriendAdded(conn *Conn, token uint32, args *v1.FriendNotification) {
conn.SendResponseCode(token, ERROR_RPC_NOT_IMPLEMENTED)
}
func (e EmptyFriendsListener) OnFriendRemoved(conn *Conn, token uint32, args *v1.FriendNotification) {
conn.SendResponseCode(token, ERROR_RPC_NOT_IMPLEMENTED)
}
func (e EmptyFriendsListener) OnReceivedInvitationAdded(conn *Conn, token uint32, args *v1.InvitationNotification) {
conn.SendResponseCode(token, ERROR_RPC_NOT_IMPLEMENTED)
}
func (e EmptyFriendsListener) OnReceivedInvitationRemoved(conn *Conn, token uint32, args *v1.InvitationNotification) {
conn.SendResponseCode(token, ERROR_RPC_NOT_IMPLEMENTED)
}
func (e EmptyFriendsListener) OnSentInvitationAdded(conn *Conn, token uint32, args *v1.SentInvitationAddedNotification) {
conn.SendResponseCode(token, ERROR_RPC_NOT_IMPLEMENTED)
}
func (e EmptyFriendsListener) OnSentInvitationRemoved(conn *Conn, token uint32, args *v1.SentInvitationRemovedNotification) {
conn.SendResponseCode(token, ERROR_RPC_NOT_IMPLEMENTED)
}
func (e EmptyFriendsListener) OnUpdateFriendState(conn *Conn, token uint32, args *v1.UpdateFriendStateNotification) {
conn.SendResponseCode(token, ERROR_RPC_NOT_IMPLEMENTED)
}
func (c *Conn) FriendsListener_Request_OnFriendAdded(args *v1.FriendNotification) error {
header, _, err := c.Request(FriendsListenerHash, 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) FriendsListener_Request_OnFriendRemoved(args *v1.FriendNotification) error {
header, _, err := c.Request(FriendsListenerHash, 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) FriendsListener_Request_OnReceivedInvitationAdded(args *v1.InvitationNotification) error {
header, _, err := c.Request(FriendsListenerHash, 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) FriendsListener_Request_OnReceivedInvitationRemoved(args *v1.InvitationNotification) error {
header, _, err := c.Request(FriendsListenerHash, 4, 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) FriendsListener_Request_OnSentInvitationAdded(args *v1.SentInvitationAddedNotification) error {
header, _, err := c.Request(FriendsListenerHash, 5, 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) FriendsListener_Request_OnSentInvitationRemoved(args *v1.SentInvitationRemovedNotification) error {
header, _, err := c.Request(FriendsListenerHash, 6, 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) FriendsListener_Request_OnUpdateFriendState(args *v1.UpdateFriendStateNotification) error {
header, _, err := c.Request(FriendsListenerHash, 7, 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
}