semaine::cms::sender::Sender Class Reference
#include <Sender.h>
List of all members.
Public Member Functions |
| Sender (const std::string &topicName, const std::string &datatype, const std::string &source) throw (CMSException) |
| Sender (const std::string &cmsUrl, const std::string &cmsUser, const std::string &cmsPassword, const std::string &topicName, const std::string &datatype, const std::string &source) throw (CMSException) |
const std::string | getDatatype () |
const std::string | getSource () |
void | setPeriodic (int aPeriod) throw (SEMAINEException) |
void | setEventBased () |
bool | isPeriodic () |
bool | isEventBased () |
int | getPeriod () |
void | setTimeToLive (long long aTimeToLive) throw (CMSException) |
long long | getTimeToLive () throw (CMSException) |
void | sendTextMessage (const std::string &text, long long usertime) throw (CMSException, SystemConfigurationException) |
void | sendTextMessage (const std::string &text, long long usertime, const std::string &contentID, long long contentCreationTime, const std::string &contentType="") throw (CMSException, SystemConfigurationException) |
void | sendTextMessage (const std::string &text, long long usertime, const std::string &eventType) throw (CMSException, SystemConfigurationException) |
void | sendTextMessage (const std::string &text, long long usertime, const std::string &eventType, const std::string &contentID, long long contentCreationTime, const std::string &contentType="") throw (CMSException, SystemConfigurationException) |
Protected Member Functions |
void | initialise () throw (CMSException) |
virtual void | fillMessageProperties (Message *message, long long usertime) throw (CMSException) |
void | fillMessageProperties (Message *message, long long usertime, const std::string &contentID, long long contentCreationTime, const std::string &contentType="") throw (CMSException) |
Protected Attributes |
MessageProducer * | producer |
const std::string | datatype |
const std::string | source |
int | period |
Detailed Description
This class handles the common part to all message senders in the SEMAINE system.
- Author:
- marc
Constructor & Destructor Documentation
semaine::cms::sender::Sender::Sender |
( |
const std::string & |
topicName, |
|
|
const std::string & |
datatype, |
|
|
const std::string & |
source | |
|
) |
| | throw (CMSException) |
Create a new Sender to the given topic on the default JMS server. The default JMS server is determined as follows:
-
jms URL: default value
tcp://localhost:61616
;
-
jms User: default value empty;
-
jms Password: default value empty.
Datatype and source will be sent with every message.
- Parameters:
-
| topic | the name of the topic to send to. |
| datatype | the name of the type of data being sent. |
| source | the name of the component sending the data. |
- Exceptions:
-
semaine::cms::sender::Sender::Sender |
( |
const std::string & |
cmsUrl, |
|
|
const std::string & |
cmsUser, |
|
|
const std::string & |
cmsPassword, |
|
|
const std::string & |
topicName, |
|
|
const std::string & |
datatype, |
|
|
const std::string & |
source | |
|
) |
| | throw (CMSException) |
Create a new CMS IOBase connection with the given topic on the given JMS server.
- Parameters:
-
| cmsUrl | the url where to contact the JMS server |
| cmsUser | the username to use (can be an empty string) |
| cmsPassword | the password to use (can be an empty string) |
| topicName | the name of the topic to send to. |
| datatype | the name of the type of data being sent. |
| source | the name of the component sending the data. |
- Exceptions:
-
Member Function Documentation
void semaine::cms::sender::Sender::fillMessageProperties |
( |
Message * |
message, |
|
|
long long |
usertime, |
|
|
const std::string & |
contentID, |
|
|
long long |
contentCreationTime, |
|
|
const std::string & |
contentType = "" | |
|
) |
| | throw (CMSException) [inline, protected] |
virtual void semaine::cms::sender::Sender::fillMessageProperties |
( |
Message * |
message, |
|
|
long long |
usertime | |
|
) |
| | throw (CMSException) [inline, protected, virtual] |
Fill in the usual message properties as far as possible. Subclasses are encouraged to override this method, but should normally call this method as well (as super.fillMessageProperties(message, usertime)
).
- Parameters:
-
| a | pointer to a message object in preparation for sending. |
| usertime | the "user" time that this message refers to, in milliseconds since system startup. |
Reimplemented in semaine::cms::sender::XMLSender.
const std::string semaine::cms::sender::Sender::getDatatype |
( |
|
) |
[inline] |
The name of the data type sent.
- Returns:
- a non-null and non-empty string.
int semaine::cms::sender::Sender::getPeriod |
( |
|
) |
[inline] |
For periodic senders, get the period of sending.
- Returns:
- An integer representing the period of sending, in milliseconds.
const std::string semaine::cms::sender::Sender::getSource |
( |
|
) |
[inline] |
The name of the source component sending the data.
- Returns:
- a non-null and non-empty string.
long long semaine::cms::sender::Sender::getTimeToLive |
( |
|
) |
throw (CMSException) [inline] |
Get the time to live for all messages sent by this sender, i.e. the number of milliseconds before the message is considered obsolete by the JMS system. Messages that are not delivered by their expiration time are deleted by the JMS system.
- Returns:
- time to live, in milliseconds. A value of 0 means unlimited time, i.e. the messages will not expire.
void semaine::cms::sender::Sender::initialise |
( |
|
) |
throw (CMSException) [protected] |
bool semaine::cms::sender::Sender::isEventBased |
( |
|
) |
[inline] |
Test whether this sender is set to send messages in an event-based way.
- Returns:
- true if sender is set to event-based, false otherwise.
bool semaine::cms::sender::Sender::isPeriodic |
( |
|
) |
[inline] |
Test whether this sender is set to send messages periodically.
- Returns:
- true if sender is set to periodic, false otherwise.
void semaine::cms::sender::Sender::sendTextMessage |
( |
const std::string & |
text, |
|
|
long long |
usertime, |
|
|
const std::string & |
eventType, |
|
|
const std::string & |
contentID, |
|
|
long long |
contentCreationTime, |
|
|
const std::string & |
contentType = "" | |
|
) |
| | throw (CMSException, SystemConfigurationException) |
Send a text message via this sender, for event-based messages. This will send a message to the registered topic with the following message properties:
-
datatype
is a String property containing the value produced by getDatatype();
-
source
is a String property containing the value produced by getSource();
-
usertime
is a long property containing the value of parameter usertime
;
-
event
is a String property containing the String representation of the event parameter to this method.
Furthermore, if getTimeToLive() returns a non-zero value, the message will contain a header field JMSExpiration
containing the time when the message will expire.
- Parameters:
-
| text | the message text. |
| usertime | the "user" time at which this message is being sent, in milliseconds since system startup. |
| eventType | the type of event represented by this message. |
| contentID | a unique identifier for the message's content. If this is not the empty string, it will cause the addition of the String property content-id in the message. |
| contentCreationTime | the time when the content in this message was created. If this is not negative, it will cause the addition of the Long property content-creation-time in the message. |
| contentType | an optional content type for the message's content; The value may be one of SEMAINEMessage::CONTENT_TYPE_UTTERANCE, SEMAINEMessage::CONTENT_TYPE_LISTENERVOCALISATION, SEMAINEMessage::CONTENT_TYPE_VISUALONLY, or any other string. |
- Exceptions:
-
| SystemConfigurationException | if the connection is not started or the sender is in periodic mode. |
void semaine::cms::sender::Sender::sendTextMessage |
( |
const std::string & |
text, |
|
|
long long |
usertime, |
|
|
const std::string & |
eventType | |
|
) |
| | throw (CMSException, SystemConfigurationException) |
Send a text message via this sender, for event-based messages. This will send a message to the registered topic with the following message properties:
-
datatype
is a String property containing the value produced by getDatatype();
-
source
is a String property containing the value produced by getSource();
-
usertime
is a long property containing the value of parameter usertime
;
-
event
is a String property containing the String representation of the event parameter to this method.
Furthermore, if getTimeToLive() returns a non-zero value, the message will contain a header field JMSExpiration
containing the time when the message will expire.
- Parameters:
-
| text | the message text. |
| usertime | the "user" time at which this message is being sent, in milliseconds since system startup. |
| event | the type of event represented by this message. |
- Exceptions:
-
| IllegalStateException | if the connection is not started or the sender is in periodic mode. |
void semaine::cms::sender::Sender::sendTextMessage |
( |
const std::string & |
text, |
|
|
long long |
usertime, |
|
|
const std::string & |
contentID, |
|
|
long long |
contentCreationTime, |
|
|
const std::string & |
contentType = "" | |
|
) |
| | throw (CMSException, SystemConfigurationException) |
Send a text message via this sender. This will send a message to the registered topic with the following message properties:
-
datatype
is a String property containing the value produced by getDatatype();
-
source
is a String property containing the value produced by getSource();
-
usertime
is a long property containing the value of parameter usertime
;
-
if the message is periodic (isPeriodic() returns
true
), period
is an int property containing the value returned by getPeriod();
-
else, the message is event-based.
event
is a String property; as this method does not specify an event type, the default value single
is assumed.
Furthermore, if getTimeToLive() returns a non-zero value, the message will contain a header field JMSExpiration
containing the time when the message will expire.
- Parameters:
-
| text | the message text. |
| usertime | the "user" time at which this message is being sent, in milliseconds since system startup. |
| contentID | a unique identifier for the message's content. If this is not the empty string, it will cause the addition of the String property content-id in the message. |
| contentCreationTime | the time when the content in this message was created. If this is not negative, it will cause the addition of the Long property content-creation-time in the message. |
| contentType | an optional content type for the message's content; The value may be one of SEMAINEMessage::CONTENT_TYPE_UTTERANCE, SEMAINEMessage::CONTENT_TYPE_LISTENERVOCALISATION, SEMAINEMessage::CONTENT_TYPE_VISUALONLY, or any other string. If this is not the empty string, it will cause the addition of the String property content-type in the message. |
- Exceptions:
-
| SystemConfigurationException | if the connection is not started or the sender is in event-based mode. |
void semaine::cms::sender::Sender::sendTextMessage |
( |
const std::string & |
text, |
|
|
long long |
usertime | |
|
) |
| | throw (CMSException, SystemConfigurationException) |
Send a text message via this sender. This will send a message to the registered topic with the following message properties:
-
datatype
is a String property containing the value produced by getDatatype();
-
source
is a String property containing the value produced by getSource();
-
usertime
is a long property containing the value of parameter usertime
;
-
if the message is periodic (isPeriodic() returns
true
), period
is an int property containing the value returned by getPeriod();
-
else, the message is event-based.
event
is a String property; as this method does not specify an event type, the default value single
is assumed.
Furthermore, if getTimeToLive() returns a non-zero value, the message will contain a header field JMSExpiration
containing the time when the message will expire.
- Parameters:
-
| text | the message text. |
| usertime | the "user" time at which this message is being sent, in milliseconds since system startup. |
- Exceptions:
-
| SystemConfigurationException | if the connection is not started or the sender is in event-based mode. |
void semaine::cms::sender::Sender::setEventBased |
( |
|
) |
[inline] |
Determine that the data is event-based, not periodic. Individual messages can transport different kinds of events,
- See also:
- sendTextMessage().
void semaine::cms::sender::Sender::setPeriodic |
( |
int |
aPeriod |
) |
throw (SEMAINEException) [inline] |
Determine that the data is periodic, and set the period in which data is (intended to be) sent, in milliseconds.
- Parameters:
-
| aPeriod | the period in which data is to be sent. |
- Exceptions:
-
| SEMAINEException | if aPeriod is <= 0. |
void semaine::cms::sender::Sender::setTimeToLive |
( |
long long |
aTimeToLive |
) |
throw (CMSException) [inline] |
Set the time to live for all messages sent by this sender, i.e. the number of milliseconds before the message is considered obsolete by the JMS system. Messages that are not delivered by their expiration time are deleted by the JMS system.
- Parameters:
-
| aTimeToLive | time to live, in milliseconds. A value of 0 means unlimited time, i.e. the messages will not expire. |
Member Data Documentation
The name of the data type being sent.
If data is periodic, the period in which data is sent, in milliseconds. A value of 0 means not periodic. Data can be either periodic or event-based, but not both at the same time.
The name of the source component from where the data originated.
The documentation for this class was generated from the following files: