Rex's plugins for Construct2
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About

rex_backendless_message

Plugin, ACE table, Discussion thread
Dependence:
rex_backendless_api

Introduction
Send/receive messages.

Usage
Prepare
Add 
rex_backendless_api to set api id and secret key.
Class name
"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
  • SenderID: ID of sender.
  • ReceiverID: ID of receiver.
  • Title: title (i.e. header) of the message.
And some optional fields
  • 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.
And some auto-generated fields
  • messageID: objectId of this message. Auto-generated when saved.
  • created: timestamp of created this message. Auto-generated when saved.
"Condition:On send" will be triggered when sending success, get sent messageID by "Expression:LastSentMessageID".
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.
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.


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:
  • senderID,
  • receiverID,
  • category,
  • status,
  • created/update time
Follows these 5 steps to create a message filter:
  1. New filter : call "Action:1. New" to build a new message filter.
  2. 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".
  3. 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".
  4. 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".
  5. 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".
  6. 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 -

Pages
  • Action:Request to page
  • Action:Request current page
  • Action:Request next page
  • Action:Request previous page
Ordered messages would be divided into pages, which started from page 0 (0-based). Lines of each page is set at "Lines" in properties table.
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.
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.
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.
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.
  • 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
Get sender data if property "Link sender" set to "Yes"-
  • 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.
Get receiver data if property "Link receiver" set to "Yes"-
  • 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
  • Expression:Index2SenderID( index )
  • Expression:Index2ReceiverID( index )
  • Expression:Index2Title( index )
  • Expression:Index2Content( index )
  • Expression:Index2Status( index )
  • Expression:Index2MessageID( index )
  • Expression:Index2SentAt( index )
Get sender data if property "Link sender" set to "Yes"-
  • 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.
Get receiver data if property "Link receiver" set to "Yes"-
  • 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.

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-
  • Expression:LastFetchedSenderID
  • Expression:LastFetchedReceiverID
  • Expression:LastFetchedTitle
  • Expression:LastFetchedContent
  • Expression:LastFetchedStatus
  • Expression:LastFetchedMessageID
  • Expression:LastFetchedSentAt
Get sender data if property "Link sender" set to "Yes"-
  • 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.
Get receiver data if property "Link receiver" set to "Yes"-
  • 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 -
  • 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.

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.


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.


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,

Create a free web site with Weebly
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About