|
@@ -39,8 +39,8 @@ func TestProtoJSON(t *testing.T) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
c1, c2 := net.Pipe()
|
|
c1, c2 := net.Pipe()
|
|
- u1 := MakeProtocolJSON(c1, context.Background())
|
|
|
|
- u2 := MakeProtocolJSON(c2, context.Background())
|
|
|
|
|
|
+ u1 := MakeProtocolJSON(c1, context.Background(), 1000)
|
|
|
|
+ u2 := MakeProtocolJSON(c2, context.Background(), 1000)
|
|
go work(u1, "u1")
|
|
go work(u1, "u1")
|
|
go work(u2, "u2")
|
|
go work(u2, "u2")
|
|
u1.Send(json.Map{
|
|
u1.Send(json.Map{
|
|
@@ -92,8 +92,8 @@ func TestSocket(t *testing.T) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
c1, c2 := net.Pipe()
|
|
c1, c2 := net.Pipe()
|
|
- s1 := NewSocket(c1, 10, context.Background())
|
|
|
|
- s2 := NewSocket(c2, 10, context.Background())
|
|
|
|
|
|
+ s1 := NewSocket(c1, 10, context.Background(), 1000)
|
|
|
|
+ s2 := NewSocket(c2, 10, context.Background(), 1000)
|
|
go work(s1, "s1")
|
|
go work(s1, "s1")
|
|
go work(s2, "s2")
|
|
go work(s2, "s2")
|
|
log.Println(s1, s2)
|
|
log.Println(s1, s2)
|
|
@@ -117,7 +117,7 @@ func TestSocket(t *testing.T) {
|
|
func TestServer(t *testing.T) {
|
|
func TestServer(t *testing.T) {
|
|
host, port := "127.0.0.1", uint16(4500)
|
|
host, port := "127.0.0.1", uint16(4500)
|
|
newServer := func() *Server {
|
|
newServer := func() *Server {
|
|
- serv := NewServer(host, port, 10, context.Background())
|
|
|
|
|
|
+ serv := NewServer(host, port, 10, context.Background(), 1000)
|
|
log.Println(serv)
|
|
log.Println(serv)
|
|
go func() {
|
|
go func() {
|
|
socket, ok := <-serv.NewConnection()
|
|
socket, ok := <-serv.NewConnection()
|
|
@@ -137,7 +137,7 @@ func TestServer(t *testing.T) {
|
|
}
|
|
}
|
|
serv := newServer()
|
|
serv := newServer()
|
|
log.Println(serv)
|
|
log.Println(serv)
|
|
- cl := NewSocketClient(host, port, 10, context.Background())
|
|
|
|
|
|
+ cl := NewSocketClient(host, port, 10, context.Background(), 1000)
|
|
log.Println(cl)
|
|
log.Println(cl)
|
|
time.Sleep(time.Second * 20)
|
|
time.Sleep(time.Second * 20)
|
|
serv.Close()
|
|
serv.Close()
|