rex_backendless_message
Introduction
Send/receive messages.
Send/receive messages.
Usage
Class name
"Class name" in properties table is the "table name" shown at dashboard.
"Class name" in properties table is the "table name" shown at dashboard.
Send message
Sample capx
Call "Action:Set user" to set the senderID, then call "Action:Send" to send a message to receverID.
A message contains
Otherwise "Condition: On send error" will be triggered.
SenderID could be read back by "Expression:MyUserID".
Sample capx
Call "Action:Set user" to set the senderID, then call "Action:Send" to send a message to receverID.
A message contains
- SenderID: ID of sender.
- ReceiverID: ID of receiver.
- Title: title (i.e. header) of the message.
- Content: content (i.e. body) of the message. Set to "' to ignore this field.
- Category: to classify messages, like "system". Set to "' to ignore this field.
- Status: status of this message, like "unread". Set to "' to ignore this field.
- messageID: objectId of this message. Auto-generated when saved.
- created: timestamp of created this message. Auto-generated when saved.
Otherwise "Condition: On send error" will be triggered.
SenderID could be read back by "Expression:MyUserID".
Link to tables
Sample capx
Set property "Sender class name"/"Receiver class name" to the table name of linked sender/receiver data.
Set table name to "" to ignore data linking, set table name to "Users" to link the system Users table.
Sample capx
Set property "Sender class name"/"Receiver class name" to the table name of linked sender/receiver data.
Set table name to "" to ignore data linking, set table name to "Users" to link the system Users table.
Change status
Call "Action:Set status", or "Action:Set status by index" to change status of message by messageID or index of queried messages.
"Condition:On set status" will be triggered while changing success, otherwise "Condition:On set status error" will be triggered.
Call "Action:Set status", or "Action:Set status by index" to change status of message by messageID or index of queried messages.
"Condition:On set status" will be triggered while changing success, otherwise "Condition:On set status error" will be triggered.
Receive messages
There are some ways to receive messages,
There are some ways to receive messages,
- using message filter to get matched messages, or
- using messageID to get specific message.
- using index of queried messages to get specific message.
Fetch by message filter
There are 6 kinds of filter for messages:
There are 6 kinds of filter for messages:
- senderID,
- receiverID,
- category,
- status,
- created/update time
- New filter : call "Action:1. New" to build a new message filter.
- SenderID : call "Action:2. add sender" to add a senderID into filter. It will use OR operation to joint these added senderIDs. Or call "Action:2. all senders" to accept all senderID. Ignoring this step is equal to "Action:2. all senders".
- ReceiverID: call "Action:3. add receiver" to add a receiverID into filter. It will use OR operation to joint these added receiverIDs. Or call "Action:3. all receivers" to accept all receiverID. Ignoring this step is equal to "Action:3. all receivers".
- Category: call "Action:4. add category" to add a category into filter. It will use OR operation to joint these added categories. Or call "Action:4. all categories" to accept all categories. Ignoring this step is equal to "Action:4. all categories".
- Status: call "Action:5. add status" to add a status into filter. It will use OR operation to joint these added status. Or call "Action:4. all status" to accept all status. Ignoring this step is equal to "Action:4. all stauts".
- Timestamp: call "Action:6. add timestamp constraint" to add a time constraint. It will use AND operation to joint these time constraint. Or call "Action:6. all timestamps" to ignore time constraint. The input parameter "Timestamp" could be created by "Expression:Date2UnixTimestamp" in rex_date plugin. Ignoring this step is equal to "Action:6. all timestamp.
Fetching messages
After build a new message filter by above steps, call one of request actions to start fetching -
After build a new message filter by above steps, call one of request actions to start fetching -
Pages
The order of messages is set at "Order" in properties table, "Earlier to later", or "Later to earlier".
Get message count of current page by "Expression:CurMessageCount". "Condition:Last page" will return true if current page is the last page, which the message count is less than requested count.
- Action:Request to page
- Action:Request current page
- Action:Request next page
- Action:Request previous page
The order of messages is set at "Order" in properties table, "Earlier to later", or "Later to earlier".
Get message count of current page by "Expression:CurMessageCount". "Condition:Last page" will return true if current page is the last page, which the message count is less than requested count.
Start from any index
Or call "Action:Request in a range" to fetch ordered messages started from any index.
Do not mix this action with pages type requests described at previous section.
Or call "Action:Request in a range" to fetch ordered messages started from any index.
Do not mix this action with pages type requests described at previous section.
All messages
Or call "Action:Request all messages" to fetch all ordered messages .
Do not mix this action with pages type requests described at previous section.
Or call "Action:Request all messages" to fetch all ordered messages .
Do not mix this action with pages type requests described at previous section.
Receive content
Content of each message could be got together if the "Content" parameter set to "with" in each request action. Designer might request a content of a specific message by messageID later.
Content of each message could be got together if the "Content" parameter set to "with" in each request action. Designer might request a content of a specific message by messageID later.
Retrieve messages
"Condition:On received" will be triggered when received requested messages. Then use "Condition:For each message" or "Condition:For each message in a range" to retrieve these messages by these expressions.
"Condition:On received" will be triggered when received requested messages. Then use "Condition:For each message" or "Condition:For each message in a range" to retrieve these messages by these expressions.
- Expression:CurMessageIndex, which is 0-based
- Expression:CurSenderID
- Expression:CurReceiverID
- Expression:CurTitle
- Expression:CurStatus
- Expression:CurContent , if set the "Content" parameter to "with"
- Expression:CurMessageID
- Expression:CurSentAt
- Expression:CurSenderData , returns a JSON string of all sender data
- Expression:CurSenderData( key ) , returns the value of a specific key
- Expression:CurSenderData( key , default_value ) , returns default value if that key does not existed.
- Expression:CurReceiverData , returns a JSON string of all receiver data
- Expression:CurReceiverData( key ) , returns the value of a specific key
- Expression:CurReceiverData( key , default_value ) , returns default value if that key does not existed.
Fetch by index
Uses these expressions to get properties of a received message by index
Uses these expressions to get properties of a received message by index
- Expression:Index2SenderID( index )
- Expression:Index2ReceiverID( index )
- Expression:Index2Title( index )
- Expression:Index2Content( index )
- Expression:Index2Status( index )
- Expression:Index2MessageID( index )
- Expression:Index2SentAt( index )
- Expression:Index2SenderData( index ) , returns a JSON string of all sender data
- Expression:Index2SenderData( index , key ) , returns the value of a specific key
- Expression:Index2SenderData( index , key , default_value ) , returns default value if that key does not existed.
- Expression:Index2ReceiverData( index ) , returns a JSON string of all receiver data
- Expression:Index2ReceiverData( index , key ) , returns the value of a specific key
- Expression:Index2ReceiverData( index , key , default_value ) , returns default value if that key does not existed.
Messages as JSON
Get all received messages in JSON string by "Expression:MessagesToJSON", the result JSON string could be loaded into rex_taffydb object.
Get all received messages in JSON string by "Expression:MessagesToJSON", the result JSON string could be loaded into rex_taffydb object.
Fetch by messageID
Call "Action:Load by messageID", "Action:Load by index" to fetch whole message with content by messageID.
"Condition:On load by messageID" will be triggered when fetching success, otherwise "Condition:On load by messageID error" will be triggered. Get message fields by these expressions-
Call "Action:Load by messageID", "Action:Load by index" to fetch whole message with content by messageID.
"Condition:On load by messageID" will be triggered when fetching success, otherwise "Condition:On load by messageID error" will be triggered. Get message fields by these expressions-
- Expression:LastFetchedSenderID
- Expression:LastFetchedReceiverID
- Expression:LastFetchedTitle
- Expression:LastFetchedContent
- Expression:LastFetchedStatus
- Expression:LastFetchedMessageID
- Expression:LastFetchedSentAt
- Expression:LastFetchedSenderData , returns a JSON string of all sender data
- Expression:LastFetchedSenderData( key ) , returns the value of a specific key
- Expression:LastFetchedSenderData( key , default_value ) , returns default value if that key does not existed.
- Expression:LastFetchedReceiverData , returns a JSON string of all receiver data
- Expression:LastFetchedReceiverData( key ) , returns the value of a specific key
- Expression:LastFetchedReceiverData( key , default_value ) , returns default value if that key does not existed.
Remove messages
There are two ways to remove messages -
There are two ways to remove messages -
- by message filter,
- by messageID,
- by index of queried messages
Remove by messageID
Call "Action:Remove by messageID", or "Action:Remove by index" to remove a message by messageID.
"Condition:On remove by messageID complete" will be triggered when removing success. Get removed messageID by "Expression:LastRemovedMessageID".
Otherwise "Condition:On remove by messageID error" will be triggered.
Call "Action:Remove by messageID", or "Action:Remove by index" to remove a message by messageID.
"Condition:On remove by messageID complete" will be triggered when removing success. Get removed messageID by "Expression:LastRemovedMessageID".
Otherwise "Condition:On remove by messageID error" will be triggered.
Remove by message filter
It also supports removing messages picked by message filter.
First creating a new message filter described at previous section, then call "Action:Remove queried messages" to remove them.
"Condition:On remove queried messages" will be triggered when all messages removed success, otherwise "Condition:On remove queried messages error" will be triggered.
It also supports removing messages picked by message filter.
First creating a new message filter described at previous section, then call "Action:Remove queried messages" to remove them.
"Condition:On remove queried messages" will be triggered when all messages removed success, otherwise "Condition:On remove queried messages error" will be triggered.
Message count
Get filtered message count by "Action:Get messages count" after build a new message filter. The result is put at "Expression:LastMessagesCount" under "Condition:On get messages count", otherwise "Condition:On get messages count error" if requesting failed.
Get filtered message count by "Action:Get messages count" after build a new message filter. The result is put at "Expression:LastMessagesCount" under "Condition:On get messages count", otherwise "Condition:On get messages count error" if requesting failed.
Send function call
Designer could create a function call string by rex_fncallpkg plugin's "Expression:FnCallPkg", then put at title or content field to send. To run this function string, put this string in rex_fncallpkg plugin's "Action:Call function".
It is a kind of RPC, since it could transfer message into function call directly,
Designer could create a function call string by rex_fncallpkg plugin's "Expression:FnCallPkg", then put at title or content field to send. To run this function string, put this string in rex_fncallpkg plugin's "Action:Call function".
It is a kind of RPC, since it could transfer message into function call directly,