fix
This commit is contained in:
parent
ae1cb0762b
commit
38572c7976
@ -67,6 +67,7 @@ func (p *MyMsg) MarshalString(s string) []byte {
|
||||
// Marshal implements the Marshal method of MessageBody interface.
|
||||
func (p *MyMsg) Unmarshal(b []byte) error {
|
||||
defer func() {
|
||||
recover()
|
||||
}()
|
||||
|
||||
p.TYPE = binary.BigEndian.Uint32(b[:4])
|
||||
|
28
server_test.go
Normal file
28
server_test.go
Normal file
@ -0,0 +1,28 @@
|
||||
package pingtunnel
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/esrrhs/pingtunnel"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test0001(test *testing.T) {
|
||||
|
||||
my := &pingtunnel.MyMsg{
|
||||
}
|
||||
my.ID = "12345"
|
||||
my.TARGET = "111:11"
|
||||
my.TYPE = 12
|
||||
my.Data = make([]byte, 3)
|
||||
dst,_ := my.Marshal(0)
|
||||
fmt.Println("dst = ", dst)
|
||||
|
||||
|
||||
my1 := &pingtunnel.MyMsg{
|
||||
}
|
||||
my1.Unmarshal(dst)
|
||||
fmt.Println("my1 = ", my1)
|
||||
|
||||
my1.Unmarshal(dst[0:4])
|
||||
fmt.Println("my1 = ", my1)
|
||||
}
|
Loading…
Reference in New Issue
Block a user