Skip to content

Commit 8b08c83

Browse files
committed
refactor(server/socket): remove obsolete log messages
1 parent d95eba9 commit 8b08c83

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

server.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ type Io struct {
4848
onAuthentication func(params map[string]string) bool
4949
onConnection connectionEvent
5050
close chan interface{}
51-
52-
path string
51+
path string
5352
}
5453

5554
type (
@@ -105,12 +104,8 @@ func New(fns ...optionFn) *Io {
105104
var upgrader = gWebsocket.Upgrader{}
106105

107106
func (s *Io) ServeHTTP(w http.ResponseWriter, r *http.Request) {
108-
log.Printf("[+] HTTP header: %+v", r.Header)
109-
log.Printf("[+] HTTP query: %+v", r.URL.Query())
110-
111107
header := r.Header
112108
if slices.Contains(header["Connection"], "Upgrade") && header.Get("Upgrade") == "websocket" {
113-
log.Println("conection:upgrade")
114109

115110
upgrader.CheckOrigin = func(r *http.Request) bool { return true }
116111
c, err := upgrader.Upgrade(w, r, nil)
@@ -368,7 +363,6 @@ func (s *Io) handlerMessage(socket *Socket, message string) error {
368363
enginePacketType := string(message[0:1])
369364
switch enginePacketType {
370365
case engineio.MESSAGE.String():
371-
// log.Println("[socket.io] string message")
372366

373367
mess := string(message)
374368
packetType := string(message[1:2])
@@ -423,8 +417,6 @@ func (s *Io) handlerMessage(socket *Socket, message string) error {
423417

424418
switch packetType {
425419
case socket_protocol.DISCONNECT.String():
426-
// log.Println("[socket.io] disconnect message")
427-
428420
socket_nps, err := s.Of(namespace).sockets.get(socket.Id)
429421
if err != nil {
430422
return err
@@ -439,8 +431,6 @@ func (s *Io) handlerMessage(socket *Socket, message string) error {
439431
})
440432
}
441433
case socket_protocol.CONNECT.String():
442-
// log.Println("[socket.io] connect message")
443-
444434
socket_nps := socket
445435
if namespace != "/" {
446436
socketWithNamespace := Socket{
@@ -464,8 +454,6 @@ func (s *Io) handlerMessage(socket *Socket, message string) error {
464454
}
465455

466456
if s.onAuthentication != nil {
467-
// log.Printf("[socket.io] connect with auth")
468-
469457
dataJson := map[string]string{}
470458
json.Unmarshal([]byte(rawpayload), &dataJson)
471459
if !s.onAuthentication(dataJson) {
@@ -537,9 +525,11 @@ func (s *Io) handlerMessage(socket *Socket, message string) error {
537525
// case socket_protocol.BINARY_ACK.String():
538526
}
539527
case engineio.PONG.String():
540-
// println("[socket.io] client pong")
528+
// log.Println("[socket.io] received pong")
529+
541530
default:
542-
log.Println("[socket.io] un-handled message")
531+
log.Printf("[socket.io] un-handled packet type: %q\n", enginePacketType)
543532
}
533+
544534
return nil
545535
}

socket.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package socketio
33
import (
44
"errors"
55
"io"
6-
"log"
76
"net/http"
87
"net/url"
98
"sync"
@@ -136,8 +135,6 @@ func (s *Socket) Rooms() []string {
136135
}
137136

138137
func (s *Socket) disconnect() {
139-
log.Printf("[socket.io] closing socket %q", s.Id)
140-
141138
s.Conn.close()
142139
s.Conn = nil
143140
// s.rooms = []string{}

0 commit comments

Comments
 (0)