mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 15:34:38 +01:00
test session timeout
This commit is contained in:
@@ -32,6 +32,7 @@ type Session struct {
|
||||
cryptConn *network.CryptConn
|
||||
sendPackets chan packet
|
||||
clientContext *clientctx.ClientContext
|
||||
lastPacket time.Time
|
||||
|
||||
userEnteredStage bool // If the user has entered a stage before
|
||||
stageID string
|
||||
@@ -73,6 +74,7 @@ func NewSession(server *Server, conn net.Conn) *Session {
|
||||
cryptConn: network.NewCryptConn(conn),
|
||||
sendPackets: make(chan packet, 20),
|
||||
clientContext: &clientctx.ClientContext{}, // Unused
|
||||
lastPacket: time.Now(),
|
||||
sessionStart: TimeAdjusted().Unix(),
|
||||
stageMoveStack: stringstack.New(),
|
||||
}
|
||||
@@ -160,6 +162,10 @@ func (s *Session) sendLoop() {
|
||||
|
||||
func (s *Session) recvLoop() {
|
||||
for {
|
||||
if time.Now().Add(-30 * time.Second).After(s.lastPacket) {
|
||||
logoutPlayer(s)
|
||||
return
|
||||
}
|
||||
if s.closed {
|
||||
logoutPlayer(s)
|
||||
return
|
||||
@@ -181,6 +187,7 @@ func (s *Session) recvLoop() {
|
||||
}
|
||||
|
||||
func (s *Session) handlePacketGroup(pktGroup []byte) {
|
||||
s.lastPacket = time.Now()
|
||||
bf := byteframe.NewByteFrameFromBytes(pktGroup)
|
||||
opcodeUint16 := bf.ReadUint16()
|
||||
opcode := network.PacketID(opcodeUint16)
|
||||
|
||||
Reference in New Issue
Block a user