-
Notifications
You must be signed in to change notification settings - Fork 6
/
chat.go
194 lines (159 loc) · 4.2 KB
/
chat.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
185
186
187
188
189
190
191
192
193
194
// Copyright (c) 2017-2019 AccelByte Inc. All Rights Reserved.
// This is licensed software from AccelByte Inc, for limitations
// and restrictions contact your company contract manager.
package model
import (
"time"
)
type Chat interface {
Len() int
}
// ChatMessage contains user's chat
type ChatMessage struct {
ID string
From string
To string
Payload string
ReceivedAt int64
}
// PersonalChatRequest contains user's personal chat
type PersonalChatRequest struct {
*ChatMessage
}
// Type implements Message interface
func (PersonalChatRequest) Type() string {
return TypePersonalChatRequest
}
// Len implements Chat interface
func (c PersonalChatRequest) Len() int {
return len(c.Payload)
}
// PersonalChatResponse response message after sending chat request
type PersonalChatResponse struct {
*BaseResponse
}
// Type implements Message interface
func (PersonalChatResponse) Type() string {
return TypePersonalChatResponse
}
// PersonalChatNotif is the notif message for incoming chat message
type PersonalChatNotif struct {
*ChatMessage
}
// Type implements Message interface
func (PersonalChatNotif) Type() string {
return TypePersonalChatNotif
}
// PartyChatRequest contains user's party chat
type PartyChatRequest struct {
*ChatMessage
}
// Type implements Message interface
func (PartyChatRequest) Type() string {
return TypePartyChatRequest
}
// Len implements Chat interface
func (c PartyChatRequest) Len() int {
return len(c.Payload)
}
// PartyChatResponse contains user's party chat
type PartyChatResponse struct {
*BaseResponse
}
// Type implements Message interface
func (PartyChatResponse) Type() string {
return TypePartyChatResponse
}
// PartyChatNotif contains user's party chat
type PartyChatNotif struct {
*ChatMessage
}
// Type implements Message interface
func (PartyChatNotif) Type() string {
return TypePartyChatNotif
}
//
// PersonalChatHistoryRequest list of user's personal chat request
type PersonalChatHistoryRequest struct {
*BaseRequest
FriendID string
}
// Type implements Message interface
func (PersonalChatHistoryRequest) Type() string {
return TypePersonalChatHistoryRequest
}
// PersonalChatHistoryResponse list of user's personal chat response
type PersonalChatHistoryResponse struct {
*BaseResponse
FriendID string
Chat string
}
// Type implements Message interface
func (PersonalChatHistoryResponse) Type() string {
return TypePersonalChatHistoryResponse
}
// JoinDefaultChannelRequest is the request models
// for join default chat channel
type JoinDefaultChannelRequest struct {
*BaseRequest
}
// Type implements Message interface
func (JoinDefaultChannelRequest) Type() string {
return TypeJoinDefaultChannelRequest
}
// ExitAllChannel is the request models
// for join exit all chat channel request
type ExitAllChannel struct {
UserID string
Namespace string
}
// Type implements Message interface
func (ExitAllChannel) Type() string {
return TypeExitAllChannel
}
// JoinDefaultChannelResponse is the response models
// for join default chat channel response
type JoinDefaultChannelResponse struct {
*BaseResponse
ChannelSlug string `json:"channelSlug"`
}
// Type implements Message interface
func (JoinDefaultChannelResponse) Type() string {
return TypeJoinDefaultChannelResponse
}
// SendChannelChatRequest is the request models
// for sending chat channel
type SendChannelChatRequest struct {
*BaseRequest
ChannelSlug string
Payload string
}
// Type implements Message interface
func (SendChannelChatRequest) Type() string {
return TypeSendChannelChatRequest
}
// Len implements Chat interface
func (c SendChannelChatRequest) Len() int {
return len(c.Payload)
}
// SendChannelChatResponse is the response models
// for sending default chat channel response
type SendChannelChatResponse struct {
*BaseResponse
}
// Type implements Message interface
func (SendChannelChatResponse) Type() string {
return TypeSendChannelChatResponse
}
// ChannelChatNotif is the response models
// for sending default chat channel response
type ChannelChatNotif struct {
From string
ChannelSlug string
Payload string
SentAt time.Time
}
// Type implements Message interface
func (ChannelChatNotif) Type() string {
return TypeChannelChatNotif
}