SendMessage
This method is to be used to send data to the connected device specified by the Header.
It is important to use Dispose to release the memory reserved in Messages once they are no longer required as this prevents excessive memory being used over long periods of time.
Function
void SendMessage(message: object, header: Header);
void SendMessage(message: object, deviceID: integer);
Parameters
Name | Type | Description |
---|---|---|
message | Object | Message created using CreateMessage method |
header | Header | Header created by CreateHeader (or the DeviceID to send this message to) |
deviceID | integer | A shortcut is available with SendMessage where it is not necessary to provide a Header, specifying the Device ID number instead. |
Return Value
Created message object
Example
var myHeader = CreateHeader(); // Create header structure
var myBody = CreateMessage("TraceRequest"); // Create message structure
myHeader.MessageID = 75;
myHeader.DeviceID = 5;
myHeader.LocationID = 2;
myHeader.DeviceRef = 0;
myBody.Barcode = "123456789000"; // Fill the members of the structure
myBody.ActionID = 1;
myBody.OperatorID = 0;
myBody.reserved = 0;
SendMessage(myBody,myHeader); // Send message
myBody.Dispose(); // Release body memory
myHeader.Dispose(); // Release header memory
In the example above, the shorter version of SendMessage will become:
SendMessage(myBody,5);