This repository was archived by the owner on Apr 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpull_form.go
More file actions
57 lines (50 loc) · 1.25 KB
/
Copy pathpull_form.go
File metadata and controls
57 lines (50 loc) · 1.25 KB
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
package messenger
import (
"net/url"
"strconv"
)
type pullForm struct {
userID string
clientID string
stickyToken string
stickyPool string
seq int
partition int
state string
cap int
messagesReceived int
idleTime int
}
func (s *Session) newPullForm() pullForm {
return pullForm{
userID: s.userID,
clientID: s.clientID,
stickyToken: "",
stickyPool: "",
seq: 0,
partition: -2,
state: "active",
cap: 8,
messagesReceived: 0,
idleTime: 0,
}
}
func (p pullForm) form() url.Values {
form := url.Values{
"channel": []string{"p_" + p.userID},
"seq": []string{strconv.Itoa(p.seq)},
"partition": []string{strconv.Itoa(p.partition)},
"clientid": []string{p.clientID},
"viewer_uid": []string{p.userID},
"uid": []string{p.userID},
"state": []string{p.state},
"idle": []string{strconv.Itoa(p.idleTime)},
"cap": []string{strconv.Itoa(p.cap)},
"msgs_recv": []string{strconv.Itoa(p.messagesReceived)},
}
if p.stickyPool != "" && p.stickyToken != "" {
form.Set("sticky_token", p.stickyToken)
form.Set("sticky_pool", p.stickyPool)
}
return form
}