Skip to content

Commit

Permalink
Disconnect reason (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom authored Jul 12, 2022
1 parent f1dd69f commit f1e2ce3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
11 changes: 11 additions & 0 deletions Runtime/Scripts/Internal/Proto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,15 @@ public enum VideoQuality
OFF = 3,
UNRECOGNIZED = -1,
}

public enum DisconnectReason {
UNKNOWN_REASON = 0,
CLIENT_INITIATED = 1,
DUPLICATE_IDENTITY = 2,
SERVER_SHUTDOWN = 3,
PARTICIPANT_REMOVED = 4,
ROOM_DELETED = 5,
STATE_MISMATCH = 6,
UNRECOGNIZED = -1,
}
}
13 changes: 10 additions & 3 deletions Runtime/Scripts/Room/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Room : JSEventEmitter<RoomEvent>, IDisposable
{
public delegate void ReconnectingDelegate();
public delegate void ReconnectedDelegate();
public delegate void DisconnectedDelegate();
public delegate void DisconnectedDelegate(DisconnectReason? reason);
public delegate void StateChangedDelegate(ConnectionState state);
public delegate void MediaDevicesChangedDelegate();
public delegate void ParticipantConnectedDelegate(RemoteParticipant participant);
Expand Down Expand Up @@ -95,9 +95,16 @@ private static void EventReceived(IntPtr iptr)
room.Reconnected?.Invoke();
break;
case RoomEvent.Disconnected:
Log.Debug("Room: Received Disconnected");
room.Disconnected?.Invoke();
{
var pPtr = JSNative.ShiftStack();
DisconnectReason? reason = null;
if(JSNative.IsNumber(pPtr))
reason = (DisconnectReason?) JSNative.GetNumber(pPtr);

Log.Debug($"Room: Received Disconnected({reason})");
room.Disconnected?.Invoke(reason);
break;
}
case RoomEvent.StateChanged:
{
var str = JSNative.GetString(JSNative.ShiftStack());
Expand Down

0 comments on commit f1e2ce3

Please sign in to comment.