func (transport *Websocket) Send(message packet.Packet) error {
	transport.writeLock.Lock()
	defer transport.writeLock.Unlock()

	if !transport.running {
		return errors.New("transport not running")
	}

	var messageType int

	if message.Binary {
		messageType = websocket.BinaryMessage
	} else {
		messageType = websocket.TextMessage
	}

	writer, err := transport.socket.NextWriter(messageType)

	if err != nil {
		return err
	}

	payload := packet.Payload{message}

	err = transport.codec.Encode(payload, writer)

	if err != nil {
		return err
	}

	return writer.Close()
}
// Send writes packet to the client socket
Send writes packet to the client socket
// Send writes packet to the client socket
func (transport *Websocket) Send(message packet.Packet) error {
	transport.writeLock.Lock()
	defer transport.writeLock.Unlock()
	if !transport.running {
		return errors.New("transport not running")
	}
	var messageType int
	if message.Binary {
		messageType = websocket.BinaryMessage
	} else {
		messageType = websocket.TextMessage
	}
	writer, err := transport.socket.NextWriter(messageType)
	if err != nil {
		return err
	}
	payload := packet.Payload{message}
	err = transport.codec.Encode(payload, writer)
	if err != nil {
		return err
	}
	return writer.Close()
}
func ( transport * Websocket ) Send ( message packet . Packet ) error { transport . writeLock . Lock ( ) defer transport . writeLock . Unlock ( ) if ! transport . running { return errors . New ( " " ) } var messageType int if message . Binary { messageType = websocket . BinaryMessage } else { messageType = websocket . TextMessage } writer , err := transport . socket . NextWriter ( messageType ) if err != nil { return err } payload := packet . Payload { message } err = transport . codec . Encode ( payload , writer ) if err != nil { return err } return writer . Close ( ) }
Send writes packet to the client socket
Send writes packet to the client socket