SendMessage Method

Publishes a message with a string payload.

Object Oriented Interface

public function doSendMessage($destination, $message);

Procedural Interface

ipworksiot_stomp_do_sendmessage($res, $destination, $message);

Remarks

This method publishes a STOMP message with a string payload to the specified Destination. The MessageOut event will fire after the message has been sent.

The ContentType property can be used to specify the content type of the payload. By default, ContentType is set to text/plain.

The STOMP specification does not place any restrictions on Destination names. Instead, each STOMP server is free to define its own requirements for, and/or interpretations of, a Destination name; for example, a server might prohibit certain characters, require a specific format, or interpret some patterns in a special manner. Be sure to consult the documentation for your STOMP server to determine how to build proper Destination names.

In addition to the payload, the outgoing messages will include:

  • All user-defined headers held by the Header* properties.
  • If the TransactionId property is populated, the transaction Id that it specifies (which associates the message with that transaction).
Note that the STOMP specification defines a number of standard headers necessary for implementing the STOMP protocol. When constructing an outgoing message, the class silently ignores any user-defined headers that are already set by the class.

If RequestReceipts is enabled when this method is called, the class will request that the server send back a receipt to confirm it has received the message. Refer to RequestReceipts for more information.

Send String Message Example

stomp1.SendMessage("test/a/b", "Hello, world!");

Send Binary Message Example

byte[] fileContent = File.ReadAllBytes("C:\test\stuff.dat");
stomp1.SendData("test/a/b", fileContent);

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks IoT 2020 PHP Edition - Version 20.0 [Build 8265]