business handles the main business logic for sending ping messages business 处理发送ping消息的主要业务逻辑
(conn ziface.IConnection)
| 14 | // business handles the main business logic for sending ping messages |
| 15 | // business 处理发送ping消息的主要业务逻辑 |
| 16 | func business(conn ziface.IConnection) { |
| 17 | for i := 0; i < 3; i++ { |
| 18 | err := conn.SendMsg(1, []byte(fmt.Sprintf("Ping %d", i+1))) |
| 19 | if err != nil { |
| 20 | fmt.Println("SendMsg error:", err) |
| 21 | break |
| 22 | } |
| 23 | |
| 24 | time.Sleep(1 * time.Second) |
| 25 | } |
| 26 | |
| 27 | // Actively disconnect after sending is complete / 发送完成后主动断开连接 |
| 28 | fmt.Println("Client actively disconnects") |
| 29 | conn.Stop() |
| 30 | } |
| 31 | |
| 32 | // DoClientConnectedBegin is the callback function when connection starts |
| 33 | // DoClientConnectedBegin 是连接开始时的回调函数 |
no test coverage detected