func (this *Callback) OnMessage(c *gotcp.Conn, p gotcp.Packet) bool { redcolPacket := p.(*redcol.RedPacket) fmt.Printf("OnMessage:[%s]\n", redcolPacket.Cmd()) redPk := &redcol.RedPacket{} redPk.SetCmd("hello", "redcol", "wrold") c.AsyncWritePacket(redPk, time.Second) return true }
func (this *Callback) OnClose(c *gotcp.Conn) { fmt.Println("OnClose:", c.GetExtraData()) }
func (this *Callback) OnConnect(c *gotcp.Conn) bool { addr := c.GetRawConn().RemoteAddr() c.PutExtraData(addr) fmt.Println("OnConnect:", addr) return true }