Cloud Code - Business Logic¶
Real-Time Database emits events which can be processed in Cloud Code to add additional logic and functionality in your application. Supported events include:
|Before client connected
||The event is emitted at the time when a Real-Time connection is established. The exact timing of the event is right before Backendless notifies the client application that the connection is established. This means the Cloud Code event handler can cancel the connection.
|After client connected
||The event is emitted after Backendless handles the connection processing and the client application is informed that the connection has been established.
||Occurs when the client disconnects from the Real-Time database.
|User logs in or logs out
||Occurs when a user logs in to or logs out from Backendless using the Backendless Login API.
Creating a Cloud Code Event Handler¶
- Login to Backendless Console and select your app.
- Click the Business Logic icon in the icon panel on the left.
- Click the EVENT HANDLERS tab.
- Click the New Event Handler link.
- Select the language of your choice in the Language drop-down list.
- Select or create a model in the Model drop-down list. To learn more about models, see the Deployment Models section of the Cloud Code development guide.
- Select Real Time Events in the Category drop-down list.
- The Event drop-down list contains a list of Real-Time events. You will see the events described in the table above. Other events in the list pertain to the Real-Time Messaging Cloud Code events. Select an event from the list. For the
clientConnectedevent, select the before or after timing.
- Click SAVE to create the event code placeholder.
The generated event handler will appear similar to the one shown below:
To edit, debug and subsequently deploy Java event handlers, the code must be downloaded first from Backendless Console:
Once the code is downloaded, follow the instructions for editing and running the code from the Java Cloud Code development guide.