The linxter message class.
Namespace:
Linxter.Common.EntitiesAssembly: Linxter.Common.Entities (in Linxter.Common.Entities.dll) Version: 1.5.0.0 (1.5.0.0)
Syntax
| C# |
|---|
public class LinxterMessage |
| Visual Basic (Declaration) |
|---|
Public Class LinxterMessage |
Examples
// Get this from the program setup screen in Linxter WebManager public const string activityID = "c856ceb1-6bf6-4cb5-a366-b2b8b0b5933d"; // Message recipient public Guid receiver1 = new Guid("7d136656-6266-4134-8750-8c29cb9b17f9"); public void CreateMessageBasic(ILinxterMessaging messagingInstance) { // Send message using LinxterMessage object // An ActivityID, is required - all other arguments are optional: LinxterMessage message = new LinxterMessage(); message.ActivityId = activityID; // Give the message a simple string for the body: message.Body = "Test message"; // Set up recipient. Note that this list can also be blank, which will // cause this message to be broadcast to all channels to which this program // instance has a connection: message.ReceiverIds.Add(receiver1); // Optionally specify other message parameters, such as attachments // Queue the message for transmission: messagingInstance.CreateMessage(message); } public void CreateMessageExtended(ILinxterMessaging messagingInstance) { // Send message using LinxterMessage object with extended options LinxterMessage message = new LinxterMessage(); message.ActivityId = activityID; message.Body = "Test message"; message.ReceiverIds.Add(receiver1); // Add a file attachment, method 1: Attachment fileAttachment = new Attachment(); ASCIIEncoding encoding = new ASCIIEncoding(); fileAttachment.FileName = "MessageAttachment.txt"; // Add attachment tags: string[] tags = { "Text Attachment", "Low Priority" }; fileAttachment.Tags = tags; // (You would typically use a stream to fill the attachment's file data - here we just use a string): fileAttachment.Data = encoding.GetBytes("A text string which will appear within the attachment"); // Add our attachment to the list: message.Attachments.Add(fileAttachment); // Add more as desired... // Add a file attachment, method 2: message.AttachmentPaths.Add("C:\\MyAttachmentsFolder\\MyMessageAttachment.docx"); // Add more as desired... // Enable message tracking (message tracking is disabled by default). This would be used in // conjunction with the MessageStatusNotification event: message.EnableMessageTracking = true; messagingInstance.MessageStatusNotification += new Action<Linxter.SDK.EventArgs.MessageTrackingEventArgs>(MyEventHandler); // Send the message via the secondary queue. This provides a second queue which can // be used, for example, for out-of-band messaging: message.SendViaSecondaryQueue = true; // Change the message priority: message.Priority = 1; // Use a message tag: message.Tags.Add("Low Priority"); // Queue the message for transmission: messagingInstance.CreateMessage(message); } void MyEventHandler(Linxter.SDK.EventArgs.MessageTrackingEventArgs obj) { if (obj.MessageStatus.Equals(MessageTrackingEvent.Delivered)) { // Do something when the message has been delivered... } }
' Get this from the program setup screen in Linxter WebManager Public Const activityID As String = "c856ceb1-6bf6-4cb5-a366-b2b8b0b5933d" ' Message recipient Public receiver1 As New Guid("7d136656-6266-4134-8750-8c29cb9b17f9") Public Sub CreateMessageBasic(ByVal messagingInstance As ILinxterMessaging) ' Send message using LinxterMessage object ' An ActivityID, is required - all other arguments are optional: Dim message As New LinxterMessage() message.ActivityId = activityID ' Give the message a simple string for the body: message.Body = "Test message" ' Set up recipient. Note that this list can also be blank, which will ' cause this message to be broadcast to all channels to which this program ' instance has a connection: message.ReceiverIds.Add(receiver1) ' Optionally specify other message parameters, such as attachments ' Queue the message for transmission: messagingInstance.CreateMessage(message) End Sub Public Sub CreateMessageExtended(ByVal messagingInstance As ILinxterMessaging) ' Send message using LinxterMessage object with extended options Dim message As New LinxterMessage() message.ActivityId = activityID message.Body = "Test message" message.ReceiverIds.Add(receiver1) ' Add a file attachment, method 1: Dim fileAttachment As New Attachment() Dim encoding As New ASCIIEncoding() fileAttachment.FileName = "MessageAttachment.txt" ' Add attachment tags: Dim tags() As String = {"Text Attachment", "Low Priority"} fileAttachment.Tags = tags ' (You would typically use a stream to fill the attachment's file data - here we just use a string): fileAttachment.Data = encoding.GetBytes("A text string which will appear within the attachment") ' Add our attachment to the list: message.Attachments.Add(fileAttachment) ' Add more as desired... ' Add a file attachment, method 2: message.AttachmentPaths.Add("C:\MyAttachmentsFolder\MyMessageAttachment.docx") ' Add more as desired... ' Enable message tracking (message tracking is disabled by default). This would be used in ' conjunction with the MessageStatusNotification event: message.EnableMessageTracking = True AddHandler messagingInstance.MessageStatusNotification, AddressOf MyEventHandler ' Send the message via the secondary queue. This provides a second queue which can ' be used, for example, for out-of-band messaging: message.SendViaSecondaryQueue = True ' Change the message priority: message.Priority = 1 ' Use a message tag: message.Tags.Add("Low Priority") ' Queue the message for transmission: messagingInstance.CreateMessage(message) End Sub Private Sub MyEventHandler(ByVal obj As Linxter.SDK.EventArgs.MessageTrackingEventArgs) If obj.MessageStatus.Equals(MessageTrackingEvent.Delivered) Then ' Do something when the message has been delivered... End If End Sub