Skip to content

Commit

Permalink
update examples and go.mod
Browse files Browse the repository at this point in the history
  • Loading branch information
lim-yoona committed Oct 10, 2023
1 parent 028e0bf commit d58ef36
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
6 changes: 3 additions & 3 deletions example/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"github.com/lim-yoona/msgpack"
"github.com/lim-yoona/tcpack"
"net"
)

Expand All @@ -16,7 +16,7 @@ func main() {
if err != nil {
fmt.Println("create tcpconn failed", err)
}
mp := msgpack.NewMsgPack(8, tcpConn)
mp := tcpack.NewMsgPack(8, tcpConn)
go func() {
for {
msg, err := mp.Unpack()
Expand All @@ -32,7 +32,7 @@ func main() {
for {
var data string
fmt.Scanln(&data)
msg := msgpack.NewMessage(0, uint32(len([]byte(data))), []byte(data))
msg := tcpack.NewMessage(0, uint32(len([]byte(data))), []byte(data))
msgByte, err := mp.Pack(msg)
if err != nil {
fmt.Println("msg pack failed:", err)
Expand Down
6 changes: 3 additions & 3 deletions example/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"github.com/lim-yoona/msgpack"
"github.com/lim-yoona/tcpack"
"net"
"time"
)
Expand All @@ -22,7 +22,7 @@ func main() {
if err != nil {
fmt.Println("return conn failed")
}
mp := msgpack.NewMsgPack(8, tcpConn)
mp := tcpack.NewMsgPack(8, tcpConn)
go func() {
for {
msg, err := mp.Unpack()
Expand All @@ -39,7 +39,7 @@ func main() {
for {
var data string
fmt.Scanln(&data)
msg := msgpack.NewMessage(0, uint32(len([]byte(data))), []byte(data))
msg := tcpack.NewMessage(0, uint32(len([]byte(data))), []byte(data))
msgByte, err := mp.Pack(msg)
if err != nil {
fmt.Println("msg pack failed:", err)
Expand Down
10 changes: 5 additions & 5 deletions example/transmitJSON.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"github.com/lim-yoona/msgpack"
"github.com/lim-yoona/tcpack"
"net"
)

Expand All @@ -19,12 +19,12 @@ func main() {
//server
listener, _ := net.ListenTCP("tcp4", address2)

msgChan := make(chan *msgpack.Imessage, 10)
msgChan := make(chan *tcpack.Imessage, 10)

go func() {
for {
tcpConnServer, _ := listener.AcceptTCP()
mpServer := msgpack.NewMsgPack(8, tcpConnServer)
mpServer := tcpack.NewMsgPack(8, tcpConnServer)
for {
msgRev, _ := mpServer.Unpack()
msgChan <- &msgRev
Expand All @@ -38,15 +38,15 @@ func main() {
fmt.Println("create tcpConn failed")
}

mpClient := msgpack.NewMsgPack(8, tcpConnClient)
mpClient := tcpack.NewMsgPack(8, tcpConnClient)

jack := &Person{
Name: "jack",
Age: 20,
}
data, _ := json.Marshal(jack)
fmt.Println("send JSON:", string(data))
msgSend := msgpack.NewMessage(0, uint32(len(data)), data)
msgSend := tcpack.NewMessage(0, uint32(len(data)), data)
msgSendByte, _ := mpClient.Pack(msgSend)
_, _ = tcpConnClient.Write(msgSendByte)

Expand Down
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ module github.com/lim-yoona/tcpack

go 1.20

require (
github.com/lim-yoona/msgpack v0.1.0
github.com/smartystreets/goconvey v1.8.1
)
require github.com/smartystreets/goconvey v1.8.1

require (
github.com/gopherjs/gopherjs v1.17.2 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25d
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/lim-yoona/msgpack v0.1.0 h1:sAULeEVw0RpF9iujzIFzAYntuE/dFd9v6yLqhWZKAPU=
github.com/lim-yoona/msgpack v0.1.0/go.mod h1:w/GynN0+bueeewRWfznv51+auiQuX1O/BSp41dAHFWk=
github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY=
github.com/smarty/assertions v1.15.0/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec=
github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY=
Expand Down

0 comments on commit d58ef36

Please sign in to comment.