// Send sends a packet to a given connection
Send sends a packet to a given connection
// Send sends a packet to a given connection
func (c *Connection) Send(packet *Packet) error {
	messageEncoded, err := protobuf.Encode(packet)
	if err != nil {
		return fmt.Errorf("error while serializing the packet to send: %s", err)
	}
	err = c.Conn.SetWriteDeadline(time.Now().Add(time.Duration(writeDeadline) * time.Second))
	if err != nil {
		return fmt.Errorf("error while setting write deadline: %s", err)
	}
	_, err = c.Conn.Write(messageEncoded)
	if err != nil {
		return fmt.Errorf("error while sending packet to %s: %s", c.Conn.RemoteAddr(), err)
	}
	return nil
}
func ( c * Connection ) Send ( packet * Packet ) error { messageEncoded , err := protobuf . Encode ( packet ) if err != nil { return fmt . Errorf ( " " , err ) } err = c . Conn . SetWriteDeadline ( time . Now ( ) . Add ( time . Duration ( writeDeadline ) * time . Second ) ) if err != nil { return fmt . Errorf ( " " , err ) } _ , err = c . Conn . Write ( messageEncoded ) if err != nil { return fmt . Errorf ( " " , c . Conn . RemoteAddr ( ) , err ) } return nil }
Send sends a packet to a given connection
Send sends a packet to a given connection
// encode message // send message