This topic describes the callback and listener operations of the Unity SDK.

Contents

API Description Supported earliest version
OnJoinChannelNotify The callback for the membership result. 1.15
OnPublishNotify The callback for the stream ingest result. 1.15
OnSubscribeNotify The callback for the subscription result. 1.15
OnRemoteUserOnLineNotify Remote user launch callback. 1.15
OnRemoteUserOffLineNotify Remote user offline callback. 1.15
OnRemoteTrackAvailableNotify Callback when the audio and video streams of remote users change. 1.15
OnSubscribeChangedNotify Subscription change callback. 1.15
OnNetworkQualityChangedNotify Network quality change callback. 1.15
OnConnectionLostNotify The callback for network connection disconnection. 1.15
OnTryToReconnectNotify The network connection is trying to reconnect the callback. 1.15
OnConnectionRecoveryNotify Callback for successful network connection reconnection. 1.15
OnByeNotify Callback when the server is kicked out or the channel is closed. 1.15
OnOccurWarningNotify Warning callback. 1.15
OnOccurErrorNotify Error callback. 1.15
OnLeaveChannelResultNotify Leave the channel result callback. 1.15
OnUpdateRoleNotify Notify when the user role changes. 1.15

Details

  • OnJoinChannelNotify: the callback for the membership result.

    public delegate void OnJoinChannelNotifyHandler(int errorCode);
    Parameter Type Description
    errorCode int The error code. 0 indicates success.
  • OnPublishNotify: callback for stream ingest results.

    public delegate void OnPublishNotifyHandler(int errorCode);
    Parameter Type Description
    errorCode int The error code. 0 indicates success.
  • OnSubscribeNotify: the callback for subscription results.

    public delegate void OnSubscribeNotifyHandler(string userId, int videoTrack, int audioTrack);
    Parameter Type Description
    userId string The ID of the remote user.
    videoTrack int Subscribe to a successful video stream.
    audioTrack int Subscribe to a successful audio stream.
  • OnRemoteUserOnLineNotify: remote user online callback.

    public delegate void OnRemoteUserOnLineNotifyHandler(string userId);
    Parameter Type Description
    userId string The ID of the remote user.
  • OnRemoteUserOffLineNotify: remote user offline callback.

    public delegate void OnRemoteUserOffLineNotifyHandler(string userId);
    Parameter Type Description
    userId string The ID of the remote user.
  • OnRemoteTrackAvailableNotify: callback when the audio and video streams of remote users change.

    public delegate void OnRemoteTrackAvailableNotifyHandler(string userId, int audioTrack, int videoTrack);
    Parameter Type Description
    userId string The ID of the remote user.
    videoTrack int Subscribe to a successful video stream.
    audioTrack int Subscribe to a successful audio stream.
  • OnSubscribeChangedNotify: Subscription change callback.

    public delegate void OnSubscribeChangedNotifyHandler(string userId, int audioTrack, int videoTrack);
    Parameter Type Description
    userId string The ID of the remote user.
    videoTrack int The video stream after the remote user changes.
    audioTrack int The audio stream after the remote user changes.
  • OnNetworkQualityChangedNotify: callback for network quality change.

    public delegate void OnNetworkQualityChangedNotifyHandler(string userId, int upQuality, int downQuality);
    Parameter Type Description
    userId string The ID of the user whose network quality has changed. If the user ID is empty, it means local, and others means remote.
    upQuality int Upstream network quality.
    downQuality int The downstream network quality.
  • OnConnectionLostNotify: the callback for network disconnection.

    public delegate void OnConnectionLostNotifyHandler();
  • OnTryToReconnectNotify: The network connection is attempting to reconnect the callback.

    public delegate void OnTryToReconnectNotifyHandler();
  • OnConnectionRecoveryNotify: the callback for successful network connection reconnection.

    public delegate void OnConnectionRecoveryNotifyHandler();
  • OnByeNotify: callback when the server is kicked out or the channel is closed.

    public delegate void OnByeNotifyHandler(int code);
    Parameter Type Description
    code int The type of the message. Valid values:
    • 1: kicked out by the server.
    • 2: The channel is closed.
    • 3: The same user ID is logged on to another end and kicked out by the server.
  • OnOccurWarningNotify: warning callback.

    public delegate void OnOccurWarningNotifyHandler(int code);
    Parameter Type Description
    code int The type of the warning.
  • OnOccurErrorNotify: error callback.

    public delegate void OnOccurErrorNotifyHandler(int error);
    Parameter Type Description
    code int The type of the error that occurred.
  • OnLeaveChannelResultNotify: Leave the channel result callback.

    public delegate void OnLeaveChannelResultHandler(int result);
    Parameter Type Description
    result int 0 is returned for success and an error code is returned for failure.
  • OnUpdateRoleNotify: Notifications when user roles change.

    public delegate void OnUpdateRoleNotifyHandler(int oldRole, int newRole);
    Parameter Type Description
    oldRole int The type of the role before the change.
    newRole int The type before and after the change.