Exemplo n.º 1
0
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
}
Exemplo n.º 2
0
func (this *Callback) OnClose(c *gotcp.Conn) {
	fmt.Println("OnClose:", c.GetExtraData())
}
Exemplo n.º 3
0
func (this *Callback) OnConnect(c *gotcp.Conn) bool {
	addr := c.GetRawConn().RemoteAddr()
	c.PutExtraData(addr)
	fmt.Println("OnConnect:", addr)
	return true
}