Пример #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
}
Пример #2
0
func (this *Callback) OnClose(c *gotcp.Conn) {
	fmt.Println("OnClose:", c.GetExtraData())
}
Пример #3
0
func (this *Callback) OnConnect(c *gotcp.Conn) bool {
	addr := c.GetRawConn().RemoteAddr()
	c.PutExtraData(addr)
	fmt.Println("OnConnect:", addr)
	return true
}