MCPcopy
hub / github.com/davyxu/cellnet / echo_StartClient

Function echo_StartClient

tests/echo_test.go:77–107  ·  view source on GitHub ↗
(echoContext *echoContext)

Source from the content-addressed store, hash-verified

75}
76
77func echo_StartClient(echoContext *echoContext) {
78 queue := cellnet.NewEventQueue()
79
80 p := peer.NewGenericPeer(echoContext.Protocol+".Connector", echoContext.Protocol+"client", echoContext.Address, queue)
81
82 proc.BindProcessorHandler(p, echoContext.Processor, func(ev cellnet.Event) {
83
84 switch msg := ev.Message().(type) {
85 case *cellnet.SessionConnected:
86 fmt.Println("client connected")
87 ev.Session().Send(&TestEchoACK{
88 Msg: "hello",
89 Value: 1234,
90 })
91 case *TestEchoACK:
92
93 fmt.Printf("client recv %+v\n", msg)
94
95 echoContext.Tester.Done(1)
96
97 case *cellnet.SessionClosed:
98 fmt.Println("client closed")
99 }
100 })
101
102 p.Start()
103
104 queue.StartLoop()
105
106 echoContext.Tester.WaitAndExpect("not recv data", 1)
107}
108
109func runEcho(t *testing.T, index int) {
110

Callers 1

runEchoFunction · 0.85

Calls 10

StartLoopMethod · 0.95
NewEventQueueFunction · 0.92
NewGenericPeerFunction · 0.92
BindProcessorHandlerFunction · 0.92
DoneMethod · 0.80
WaitAndExpectMethod · 0.80
MessageMethod · 0.65
SendMethod · 0.65
SessionMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected