Skip to content

Commit

Permalink
Update server.go
Browse files Browse the repository at this point in the history
  • Loading branch information
MCausc78 authored Oct 3, 2023
1 parent ad76e9b commit 0f5a3c8
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gorcon

import (
"fmt"
"io"
"net"
"reflect"
)
Expand Down Expand Up @@ -228,13 +229,7 @@ func (cctx *RCONCommandContext) Reply(payload string) error {

func (rs *RCONServer) handleConnection(conn net.Conn) {
ctx := NewContext(conn, rs)
defer func() {
if err := ctx.Connection.Close(); err != nil {
if rs.ErrorHandler != nil {
rs.ErrorHandler(nil, ctx, err)
}
}
}()
defer ctx.Close()
packet, err := ctx.RecvPacket()
if err != nil {
if rs.ErrorHandler != nil {
Expand Down Expand Up @@ -275,6 +270,9 @@ func (rs *RCONServer) handleConnection(conn net.Conn) {
for !ctx.Closed {
packet, err := ctx.RecvBinaryPacket()
if err != nil {
if err == io.EOF {
break
}
if rs.ErrorHandler != nil {
rs.ErrorHandler(nil, ctx, err)
}
Expand Down

0 comments on commit 0f5a3c8

Please sign in to comment.