-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_panels.go
60 lines (51 loc) · 1.31 KB
/
user_panels.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
package handler
import (
"fmt"
"github.com/bnch/lan/packets"
)
// This files contains all the handlers related to changing the user panels in
// f9, even indirectly (such as logout etc.).
// Set the user's state to that requested to have.
func sendUserState(p *packets.OsuSendUserState, s Session) {
s.State = *p
SaveSession(s)
}
// Log out the user
func osuExit(p *packets.OsuExit, s Session) {
fmt.Printf("> %s has logged out\n", s.Username)
s.Dispose()
Sessions.Send(&packets.BanchoUserQuit{ID: s.UserID, State: 0})
}
func userStatsRequest(p *packets.OsuUserStatsRequest, s Session) {
// Send to osu! information about the users it requests.
for _, i := range p.IDs {
u := GetSession(Sessions.TokenFromID(i))
if u == nil {
continue
}
s.Send(u.ToHandleUserUpdate())
}
}
func userPresenceRequest(p *packets.OsuUserPresenceRequest, s Session) {
// Send to osu! information about the users it requests.
for _, i := range p.IDs {
u := GetSession(Sessions.TokenFromID(i))
if u == nil {
continue
}
s.Send(u.ToUserPresence())
}
}
func updateUserStats(p *packets.OsuRequestStatusUpdate, s Session) {
s.Send(s.ToHandleUserUpdate())
// Should also be sent to spectators if any
}
func init() {
RegisterHandlers(
sendUserState,
osuExit,
userStatsRequest,
userPresenceRequest,
updateUserStats,
)
}