How do I determine whether connecting to a room failed?
When I call realtime.Connect(), I need to determine if the method failed. There's already a didConnectToRoom event, but not one for if it fails.
didConnectToRoomevent RealtimeEvent didConnectToRoom
An event that is fired when Realtime is connected to a room and all realtime prefabs and realtime views in the scene have been successfully connected to the datastore.
true when the instance is successfully connected to a room and all realtime prefabs and realtime views in the scene have been successfully connected to the datastore. RealtimeRealtimeRealtimeRealtimeconnectedconnectedconnectedconnectedconnectedconnectedfalsefalsefalsedidConnectToRoomdidConnectToRoomDidConnectToRoom_realtime.connectedprivate void Start() {
// Notify us when Realtime successfully connects to the room
_realtime.didConnectToRoom += DidConnectToRoom;
// Connect to "My Room"
_realtime.Connect("My Room");
// Check if connection was successful
if (!_realtime.connected) {
Debug.Log("Failed to connect to room.");
}
} private void Start() {
// Notify us when Realtime successfully connects to the room
_realtime.didConnectToRoom += DidConnectToRoom;
// Connect to "My Room"
_realtime.Connect("My Room");
}
private void DidConnectToRoom(Realtime realtime) {
// Connection successful
Debug.Log("Connected to room.");
}