/**
GET BINARY DATA
*/
func (r RelayResponse) GetData() []byte {

	buf := new(bytes.Buffer)
	utils.Write(buf, r.Body)

	return buf.Bytes()
}
/**
GET BINARY DATA
*/
func (r RelayRequest) GetData() []byte {

	buf := new(bytes.Buffer)
	utils.Uint64ListToByteArray(buf, r.Receivers)
	utils.Write(buf, r.Body)

	return buf.Bytes()
}
/**
SEND REQUEST
*/
func (t *TcpMessageClient) sendRequest(request messages.Message) error {

	// Encode request
	encoded := messages.Encode(request)

	// Send request
	err := utils.Write(t.conn, encoded)

	if err != nil {
		fmt.Println("Error sending request:", err.Error())
		return err
	}

	return nil
}
func (t *TcpMessageHub) handleResponse(response messages.Response) error {

	// Encode response
	encoded := messages.Encode(response)

	// Send the responses
	for _, id := range response.GetReceiverIds() {

		err := utils.Write(t.conns[id], encoded)

		if err != nil {
			fmt.Println("Error sending response:", err.Error())
			return err
		}
	}

	return nil
}