#!/bin/sh
# Revision: $Id: mom_unicast 51847 2018-03-06 14:55:07Z kristov $
#
# Sends a message to an endpoint. The message data is passed in variables
# that are named <message-type>_<parameter>.
#
# $1 = endpoint to receive this message
# $2 = type of message to be sent
# $3 = (optional) type of message to be received as a reply
# $4 = (optional) timeout for waiting for the reply
# Output: If no reply has been requested, no output exists. Otherwise, the
#         parameters of the reply message are printed if the reply arrives in
#         time.
# Returns: 0 on success and non-zero on failure

. /usr/share/mom/core

ep=$1
type=$2
reply_type=$3
timeout=$4

if [ -n "$reply_type" ]; then
	mom_unicast_message_and_receive_reply "$ep" "$type" "$reply_type" $timeout
else
	id=$(mom_unicast_message "$ep" "$type")
fi
