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

Function echo_StartServer

tests/echo_test.go:47–75  ·  view source on GitHub ↗
(context *echoContext)

Source from the content-addressed store, hash-verified

45)
46
47func echo_StartServer(context *echoContext) {
48 queue := cellnet.NewEventQueue()
49
50 context.Acceptor = peer.NewGenericPeer(context.Protocol+".Acceptor", context.Protocol+"server", context.Address, queue)
51
52 proc.BindProcessorHandler(context.Acceptor, context.Processor, func(ev cellnet.Event) {
53
54 switch msg := ev.Message().(type) {
55 case *cellnet.SessionAccepted:
56 fmt.Println("server accepted")
57 case *TestEchoACK:
58
59 fmt.Printf("server recv %+v\n", msg)
60
61 ev.Session().Send(&TestEchoACK{
62 Msg: msg.Msg,
63 Value: msg.Value,
64 })
65
66 case *cellnet.SessionClosed:
67 fmt.Println("session closed: ", ev.Session().ID())
68 }
69
70 })
71
72 context.Acceptor.Start()
73
74 queue.StartLoop()
75}
76
77func echo_StartClient(echoContext *echoContext) {
78 queue := cellnet.NewEventQueue()

Callers 1

runEchoFunction · 0.85

Calls 9

StartLoopMethod · 0.95
NewEventQueueFunction · 0.92
NewGenericPeerFunction · 0.92
BindProcessorHandlerFunction · 0.92
MessageMethod · 0.65
SendMethod · 0.65
SessionMethod · 0.65
IDMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected