示例#1
0
func (p *playerClient) EchoMessage(msg string) {
	p.player.Enqueue(func(_ *Player) {
		buf := new(bytes.Buffer)
		proto.WriteChatMessage(buf, msg)
		p.TransmitPacket(buf.Bytes())
	})
}
示例#2
0
func (game *Game) BroadcastMessage(msg string) {
	buf := new(bytes.Buffer)
	proto.WriteChatMessage(buf, msg)

	game.enqueue(func(_ *Game) {
		game.multicastPacket(buf.Bytes(), nil)
	})
}
示例#3
0
func (player *Player) sendChatMessage(message string, sendToSelf bool) {
	buf := new(bytes.Buffer)
	proto.WriteChatMessage(buf, message)

	packet := buf.Bytes()

	if sendToSelf {
		player.TransmitPacket(packet)
	}

	player.chunkSubs.curShard.ReqMulticastPlayers(
		player.chunkSubs.curChunkLoc,
		player.EntityId,
		packet,
	)
}
示例#4
0
func (game *Game) BroadcastMessage(msg string) {
	buf := new(bytes.Buffer)
	proto.WriteChatMessage(buf, msg)
	game.BroadcastPacket(buf.Bytes())
}