Skip to content

Commit

Permalink
Merge branch 'main' into fix/packet-queue
Browse files Browse the repository at this point in the history
  • Loading branch information
sekaiwish committed Feb 17, 2025
2 parents d1dfc3f + 7c61f70 commit d86f50b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 11 additions & 0 deletions server/channelserver/sys_channel_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ func (s *Server) Start() error {

go s.acceptClients()
go s.manageSessions()
go s.invalidateSessions()

// Start the discord bot for chat integration.
if s.erupeConfig.Discord.Enabled && s.discordBot != nil {
Expand Down Expand Up @@ -278,6 +279,16 @@ func (s *Server) manageSessions() {
}
}

func (s *Server) invalidateSessions() {
for _, session := range s.sessions {
if time.Now().Add(-30 * time.Second).After(session.lastPacket) {
s.logger.Info("Session timeout", zap.String("Name", session.Name))
logoutPlayer(session)
}
}
time.Sleep(30 * time.Second)
}

// BroadcastMHF queues a MHFPacket to be sent to all sessions.
func (s *Server) BroadcastMHF(pkt mhfpacket.MHFPacket, ignoredSession *Session) {
// Broadcast the data.
Expand Down
4 changes: 0 additions & 4 deletions server/channelserver/sys_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ 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
Expand Down

0 comments on commit d86f50b

Please sign in to comment.