Skip to content

Enhance Disconnect Event #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Runtime/Scripts/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public class Room
public delegate void SipDtmfDelegate(Participant participant, UInt32 code, string digit);
public delegate void ConnectionStateChangeDelegate(ConnectionState connectionState);
public delegate void ConnectionDelegate(Room room);
public delegate void DisconnectDelegate(DisconnectReason reason);
public delegate void E2EeStateChangedDelegate(Participant participant, EncryptionState state);

public string Sid { private set; get; }
Expand Down Expand Up @@ -152,7 +153,7 @@ public class Room
public event SipDtmfDelegate SipDtmfReceived;
public event ConnectionStateChangeDelegate ConnectionStateChanged;
public event ConnectionDelegate Connected;
public event ConnectionDelegate Disconnected;
public event DisconnectDelegate Disconnected;
public event ConnectionDelegate Reconnecting;
public event ConnectionDelegate Reconnected;
public event E2EeStateChangedDelegate E2EeStateChanged;
Expand Down Expand Up @@ -455,7 +456,7 @@ internal void OnEventReceived(RoomEvent e)
ConnectionStateChanged?.Invoke(e.ConnectionStateChanged.State);
break;
case RoomEvent.MessageOneofCase.Disconnected:
Disconnected?.Invoke(this);
Disconnected?.Invoke(e.Disconnected.Reason);
OnDisconnect();
break;
case RoomEvent.MessageOneofCase.Reconnecting:
Expand Down Expand Up @@ -493,6 +494,8 @@ internal void OnConnect(ConnectCallback info)

private void OnDisconnectReceived(DisconnectCallback e)
{
OnDisconnect();
Disconnected?.Invoke(DisconnectReason.ClientInitiated);
FfiClient.Instance.DisconnectReceived -= OnDisconnectReceived;
Utils.Debug($"OnDisconnect.... {e}");
}
Expand Down