()
| 56 | } |
| 57 | |
| 58 | func main() { |
| 59 | // Create client / 创建客户端 |
| 60 | client := znet.NewClient("127.0.0.1", 8999) |
| 61 | |
| 62 | // Set connection start and stop callbacks / 设置连接开始和断开的回调 |
| 63 | client.SetOnConnStart(DoClientConnectedBegin) |
| 64 | client.SetOnConnStop(DoClientConnectedLost) |
| 65 | |
| 66 | // Add router / 添加路由 |
| 67 | client.AddRouter(0, &router.PingRouter{}) |
| 68 | |
| 69 | // Start client / 启动客户端 |
| 70 | fmt.Println("Client starting") |
| 71 | client.Start() |
| 72 | |
| 73 | // Wait for interrupt signal / 等待中断信号 |
| 74 | c := make(chan os.Signal, 1) |
| 75 | signal.Notify(c, os.Interrupt, os.Kill) |
| 76 | <-c |
| 77 | } |
nothing calls this directly
no test coverage detected