// SendChatMsg sends a chat message to the Peer if it isn't a server
SendChatMsg sends a chat message to the Peer if it isn't a server
// SendChatMsg sends a chat message to the Peer if it isn ' t a server
func (p *Peer) SendChatMsg(msg string) {
	if p.IsSrv() {
		return
	}
	wstr := wider([]byte(msg))
	data := make([]byte, 16+len(wstr))
	data[0] = uint8(0x00)
	data[1] = uint8(ToClientChatMessage)
	data[2] = uint8(0x01)
	data[3] = uint8(0x00)
	data[4] = uint8(0x00)
	data[5] = uint8(0x00)
	binary.BigEndian.PutUint16(data[6:8], uint16(len(msg)))
	copy(data[8:8+len(wstr)], wstr)
	data[8+len(wstr)] = uint8(0x00)
	data[9+len(wstr)] = uint8(0x00)
	data[10+len(wstr)] = uint8(0x00)
	data[11+len(wstr)] = uint8(0x00)
	binary.BigEndian.PutUint32(data[12+len(wstr):16+len(wstr)], uint32(time.Now().Unix()))
	ack, err := p.Send(rudp.Pkt{Data: data})
	if err != nil {
		log.Print(err)
	}
	<-ack
}
func ( p * Peer ) SendChatMsg ( msg string ) { if p . IsSrv ( ) { return } wstr := wider ( [ ] byte ( msg ) ) data := make ( [ ] byte , 16 + len ( wstr ) ) data [ 0 ] = uint8 ( 0x00 ) data [ 1 ] = uint8 ( ToClientChatMessage ) data [ 2 ] = uint8 ( 0x01 ) data [ 3 ] = uint8 ( 0x00 ) data [ 4 ] = uint8 ( 0x00 ) data [ 5 ] = uint8 ( 0x00 ) binary . BigEndian . PutUint16 ( data [ 6 : 8 ] , uint16 ( len ( msg ) ) ) copy ( data [ 8 : 8 + len ( wstr ) ] , wstr ) data [ 8 + len ( wstr ) ] = uint8 ( 0x00 ) data [ 9 + len ( wstr ) ] = uint8 ( 0x00 ) data [ 10 + len ( wstr ) ] = uint8 ( 0x00 ) data [ 11 + len ( wstr ) ] = uint8 ( 0x00 ) binary . BigEndian . PutUint32 ( data [ 12 + len ( wstr ) : 16 + len ( wstr ) ] , uint32 ( time . Now ( ) . Unix ( ) ) ) ack , err := p . Send ( rudp . Pkt { Data : data } ) if err != nil { log . Print ( err ) } <- ack }
SendChatMsg sends a chat message to the Peer if it isn't a server
SendChatMsg sends a chat message to the Peer if it isn ' t a server