Esempio n. 1
0
func (this *Client) SendPack(cmd int, bytes []byte) {
	buffer := tbs.CreateByteArray([]byte{})
	bufferIn := tbs.CreateByteArray([]byte{})

	bufferIn.WriteInt32(int32(cmd))
	bufferIn.WriteBytes(bytes)

	buffer.WriteInt32(int32(len(bufferIn.Bytes())))
	buffer.Write(bufferIn.Bytes())

	this.Send(buffer.Bytes())

	//fmt.Println("send:", len(bufferIn.Bytes()))
}
Esempio n. 2
0
func (this *Protocol) Deal1010(client *Client, bufferIn *tbs.ByteArray) {
	buffer := tbs.CreateByteArray([]byte{})

	buffer.WriteBool(true)

	client.SendPack(1010, buffer.Bytes())
}
Esempio n. 3
0
func (this *Protocol) Deal1012(client *Client) {
	buffer := tbs.CreateByteArray([]byte{})

	buffer.WriteInt32(int32(client.id))

	fmt.Println(client.id, "closed")

	client.Broadcast(1012, buffer.Bytes())
}
Esempio n. 4
0
func (this *Protocol) Deal1000(client *Client, bufferIn *tbs.ByteArray) {
	client.playerVo.Nickname, _ = bufferIn.ReadUTF()

	buffer := tbs.CreateByteArray([]byte{})

	buffer.WriteBool(true)
	buffer.WriteInt32(int32(client.id))

	client.SendPack(1000, buffer.Bytes())
}
Esempio n. 5
0
func (p *Protocol) Deal(client *Client, bytes []byte) {

	buffer := tbs.CreateByteArray(bytes)

	cmd, _ := buffer.ReadInt32()
	fmt.Printf("cmd[%d], len[%d]\n", cmd, len(bytes))
	_, err := tbs.Call(p, fmt.Sprintf("Deal%d", cmd), client, buffer)
	if err != nil {
		fmt.Println(err)
	}
}
Esempio n. 6
0
func (this *Protocol) Deal1011(client *Client, bufferIn *tbs.ByteArray) {
	buffer := tbs.CreateByteArray([]byte{})

	clientMap := SharedGameMain().ClientMap
	buffer.WriteInt32(int32(len(clientMap)))
	for _, client := range clientMap {
		buffer.WriteInt32(client.id)
		buffer.WriteUTF(client.playerVo.Nickname)
		buffer.WriteInt32(0)
		buffer.WriteInt32(client.playerVo.X)
		buffer.WriteInt32(client.playerVo.Y)
	}

	client.Broadcast(1011, buffer.Bytes())
}