Skip to content

Commit 1c0ea9f

Browse files
committed
Implement ClientLogout packet
1 parent 2cd492b commit 1c0ea9f

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

handlers/ClientLogout.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package handlers
2+
3+
import (
4+
"example.com/Quaver/Z/packets"
5+
"example.com/Quaver/Z/sessions"
6+
)
7+
8+
// Called when the client requests to log out.
9+
func handleClientLogout(user *sessions.User, packet *packets.ClientLogout) {
10+
if packet == nil {
11+
return
12+
}
13+
14+
err := HandleLogout(user.Conn)
15+
16+
if err != nil {
17+
return
18+
}
19+
}

handlers/packets.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ func HandleIncomingPackets(conn net.Conn, msg string) {
114114
handleClientSpectateMultiplayerGame(user, unmarshalPacket[packets.ClientSpectateMultiplayerGame](msg))
115115
case packets.PacketIdClientGameAutoHost:
116116
handleClientGameAutoHost(user, unmarshalPacket[packets.ClientGameAutoHost](msg))
117+
case packets.PacketIdClientLogout:
118+
handleClientLogout(user, unmarshalPacket[packets.ClientLogout](msg))
117119
default:
118120
log.Println(fmt.Errorf("unknown packet: %v", msg))
119121
}

packets/ClientLogout.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package packets
2+
3+
type ClientLogout struct {
4+
Packet
5+
}

packets/packet_id.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,5 @@ const (
138138
PacketIdClientGameDifficultyRatings
139139
PacketIdClientGameAutoHost
140140
PacketIdServerGameAutoHost
141+
PacketIdClientLogout
141142
)

0 commit comments

Comments
 (0)