EnableRTT
Attempts to establish an RTT connection to the brainCloud servers.
RTT must be enabled in the Design Portal, under Design | Core App Info | Advanced Settings.
RTT is available to all Plus plan subscriptions.
| Service | Operation |
|---|---|
| rttRegistration | REQUEST_CLIENT_CONNECTION |
Method Parameters
| Parameter | Description |
|---|---|
| connectionType | Type of RTT connections being established. Examples: WebSocket, TCP. |
Usage
http://localhost:3000
- C#
- C++
- Obj-C
- Java
- JavaScript
- Dart
- Roblox
- GDScript
- Lua
- Cloud Code
- Raw
// Real-time Tech (RTT) must be checked on the dashboard, under Design | Core App Info | Advanced Settings.
eRTTConnectionType rttConnectionType = eRTTConnectionType.WEBSOCKET;
SuccessCallback successCallback = (response, cbObject) =>
{
Dictionary<string, object> jsonMessage = (Dictionary<string, object>)JsonFx.Json.JsonReader.Deserialize(response);
Dictionary<string, object> jsonData = (Dictionary<string, object>)jsonMessage["data"];
string heartbeatSeconds = jsonData["heartbeatSeconds"].ToString();
string logMessage = string.Join(" | ", new [] {heartbeatSeconds});
Debug.Log(logMessage); // 30
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("[EnableRTT Failed] {0} {1} {2}", status, code, error));
};
_bc.RTTService.EnableRTT(rttConnectionType, successCallback, failureCallback);
bool useWebSocket = true;
_bc->enableRTT(useWebSocket, true);
Coming soon!
this; // implements IRTTConnectCallback
_bc.RTTService.enableRTT(this);
public void rttConnectSuccess()
{
System.out.print("Success");
}
public void rttConnectFailure(String errorMessage)
{
System.out.print(String.format("Failed | %s", errorMessage));
}
_bc.rttService.enableRTT(result =>
{
console.log(result);
}, error =>
{
console.log(error);
});
void successCallback(RTTCommandResponse response) {
// Your code
}
void failureCallback(RTTCommandResponse response) {
// Your code
}
_bc.rttRegistrationService.enableRTT(
successCallback:successCallback,
failureCallback:failureCallback);
local successCallback = function(response)
-- your code
end
local failureCallback = function(response)
-- your code
end
_bc.rttService:enableRTT(successCallback, failureCallback)
N/A
-- RTT must be enabled for the app on the Design Portal.
local onSuccess = function(message)
print("RTT enabled")
end
local onFailure = function(error)
print("RTT failed | " .. tostring(error.status_message or error))
end
_bc.rttService:enableRTT(onSuccess, onFailure)
// N/A
// N/A
JSON Response
{
"service": "rtt",
"operation": "CONNECT",
"data": {
"heartbeatSeconds": 30
}
}