File tree 3 files changed +9
-4
lines changed
3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package client
2
2
3
3
import (
4
4
"bytes"
5
- "encoding/json"
6
5
"fmt"
7
6
"io"
8
7
"log"
@@ -13,6 +12,7 @@ import (
13
12
"time"
14
13
15
14
"github.com/gorilla/websocket"
15
+ "github.com/shamaton/msgpack/v2"
16
16
)
17
17
18
18
// Message struct to match the server's message structure
@@ -124,7 +124,7 @@ func HandleClient(port string) {
124
124
}
125
125
126
126
var message Message
127
- if err := json .Unmarshal (messageBytes , & message ); err != nil {
127
+ if err := msgpack .Unmarshal (messageBytes , & message ); err != nil {
128
128
log .Printf ("Received invaid response from server: %s" , string (messageBytes ))
129
129
continue
130
130
}
@@ -172,7 +172,7 @@ func HandleClient(port string) {
172
172
}
173
173
174
174
// Send response back through WebSocket
175
- responseBytes , err := json .Marshal (message )
175
+ responseBytes , err := msgpack .Marshal (message )
176
176
if err != nil {
177
177
log .Printf ("Error marshaling response: %v" , err )
178
178
continue
Original file line number Diff line number Diff line change @@ -2,7 +2,10 @@ module github.com/portsicle/portsicle-client
2
2
3
3
go 1.23.4
4
4
5
- require github.com/gorilla/websocket v1.5.3
5
+ require (
6
+ github.com/gorilla/websocket v1.5.3
7
+ github.com/shamaton/msgpack/v2 v2.2.2
8
+ )
6
9
7
10
require (
8
11
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
4
4
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8 =
5
5
github.com/inconshreveable/mousetrap v1.1.0 /go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw =
6
6
github.com/russross/blackfriday/v2 v2.1.0 /go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM =
7
+ github.com/shamaton/msgpack/v2 v2.2.2 h1:GOIg0c9LV04VwzOOqZSrmsv/JzjNOOMxnS/HvOHGdgs =
8
+ github.com/shamaton/msgpack/v2 v2.2.2 /go.mod h1:6khjYnkx73f7VQU7wjcFS9DFjs+59naVWJv1TB7qdOI =
7
9
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM =
8
10
github.com/spf13/cobra v1.8.1 /go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y =
9
11
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA =
You can’t perform that action at this time.
0 commit comments