(context *echoContext)
| 45 | ) |
| 46 | |
| 47 | func 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 | |
| 77 | func echo_StartClient(echoContext *echoContext) { |
| 78 | queue := cellnet.NewEventQueue() |
no test coverage detected