コード例 #1
0
/**
GET BINARY DATA
*/
func (r RelayResponse) GetData() []byte {

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

	return buf.Bytes()
}
コード例 #2
0
/**
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()
}
コード例 #3
0
/**
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
}
コード例 #4
0
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
}