MCPcopy Index your code
hub / github.com/aceld/zinx / main

Function main

examples/zinx_closecallback/client/client.go:58–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56}
57
58func 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}

Callers

nothing calls this directly

Calls 5

SetOnConnStartMethod · 0.95
SetOnConnStopMethod · 0.95
AddRouterMethod · 0.95
StartMethod · 0.95
NewClientFunction · 0.92

Tested by

no test coverage detected