Example #1
0
        private static void VChatSessionStatusCallback(NIMVideoChatSessionType type, long channel_id, int code, string json_extension, IntPtr user_data)
        {
            System.Diagnostics.Debug.WriteLine("type:" + type.ToString() + "json: " + json_extension);
            if (json_extension == null)
            {
                return;
            }
            NIMVChatSessionInfo info = null;

            switch (type)
            {
            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeStartRes:
            {
                if (session_status.onSessionStartRes != null)
                {
                    session_status.onSessionStartRes.DynamicInvoke(channel_id, code);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeInviteNotify:
            {
                if (session_status.onSessionInviteNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionInviteNotify.DynamicInvoke(channel_id, info.Uid, info.Type, info.Time, info.CustomInfo);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeCalleeAckRes:
            {
                if (session_status.onSessionCalleeAckRes != null)
                {
                    session_status.onSessionCalleeAckRes.DynamicInvoke(channel_id, code);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeCalleeAckNotify:
            {
                if (session_status.onSessionCalleeAckNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionCalleeAckNotify.DynamicInvoke(channel_id, info.Uid, info.Type, info.Accept > 0);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeControlRes:
            {
                if (session_status.onSessionControlRes != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionControlRes.DynamicInvoke(channel_id, code, info.Type);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeControlNotify:
            {
                if (session_status.onSessionControlNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionControlNotify.DynamicInvoke(channel_id, info.Uid, info.Type);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeConnect:
            {
                if (session_status.onSessionConnectNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionConnectNotify.DynamicInvoke(channel_id, code, info.RecordFile, info.VideoRecordFile);
                    }
                    else
                    {
                        session_status.onSessionConnectNotify.DynamicInvoke(channel_id, code, null, null);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypePeopleStatus:
            {
                if (session_status.onSessionPeopleStatus != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        if (code == Convert.ToInt32(NIMVideoChatSessionStatus.kNIMVideoChatSessionStatusLeaved))
                        {
                            if (info.Status == Convert.ToInt32(NIMVideoChatUserLeftType.kNIMVChatUserLeftTimeout))
                            {
                                code = Convert.ToInt32(NIMVideoChatSessionStatus.kNIMVideoChatSessionStatusTimeOutLeaved);
                            }
                        }
                        session_status.onSessionPeopleStatus.DynamicInvoke(channel_id, info.Uid, code);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeNetStatus:
            {
                if (session_status.onSessionNetStatus != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionNetStatus.DynamicInvoke(channel_id, code, info.Uid);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeHangupRes:
            {
                if (session_status.onSessionHangupRes != null)
                {
                    session_status.onSessionHangupRes.DynamicInvoke(channel_id, code);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeHangupNotify:
            {
                if (session_status.onSessionHangupNotify != null)
                {
                    session_status.onSessionHangupNotify.DynamicInvoke(channel_id, code);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeSyncAckNotify:
            {
                if (session_status.onSessionSyncAckNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionSyncAckNotify.DynamicInvoke(channel_id, code, info.Uid, info.Type, info.Accept > 0, info.Time, info.Client);
                    }
                }
            }
            break;

#if NIMAPI_UNDER_WIN_DESKTOP_ONLY
            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeMp4Notify:
            {
                if (session_status.onSessionMp4InfoStateNotify != null)
                {
                    NIMVChatMP4State mp4_info = NIMVChatMP4State.Deserialize(json_extension);
                    session_status.onSessionMp4InfoStateNotify(channel_id, code, mp4_info);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeInfoNotify:
                if (session_status.onSessionRealtimeStateNotify != null)
                {
                    var state = NIMVChatRealtimeState.Deserialize(json_extension);
                    session_status.onSessionRealtimeStateNotify(channel_id, code, state);
                }
                break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeVolumeNotify:
                if (session_status.onSessionVolumeStateChanged != null)
                {
                    var volume = NIMVchatAudioVolumeState.Deserialize(json_extension);
                    session_status.onSessionVolumeStateChanged(channel_id, code, volume);
                }
                break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeAuRecordNotify:
            {
                if (session_status.onSessionAuRecordInfoStateNotify != null)
                {
                    NIMVChatAuRecordState record_state = NIMVChatAuRecordState.Deserialize(json_extension);
                    session_status.onSessionAuRecordInfoStateNotify(channel_id, code, record_state);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeLiveState:
            {
                if (session_status.onSessionLiveStateNotify != null)
                {
                    var state = NIMVChatLiveState.Deserialize(json_extension);
                    session_status.onSessionLiveStateNotify(channel_id, code, state);
                }
            }
            break;
#endif
            }
        }
Example #2
0
        private static void VChatSessionStatusCallback(NIMVideoChatSessionType type, long channel_id, int code, string json_extension, IntPtr user_data)
        {
            if (json_extension == null)
            {
                return;
            }
            NIMVChatSessionInfo info = null;

            switch (type)
            {
            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeStartRes:
            {
                if (session_status.onSessionStartRes != null)
                {
                    session_status.onSessionStartRes.DynamicInvoke(channel_id, code);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeInviteNotify:
            {
                if (session_status.onSessionInviteNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    session_status.onSessionInviteNotify.DynamicInvoke(channel_id, info.Uid, info.Type, info.Time);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeCalleeAckRes:
            {
                if (session_status.onSessionCalleeAckRes != null)
                {
                    session_status.onSessionCalleeAckRes.DynamicInvoke(channel_id, code);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeCalleeAckNotify:
            {
                if (session_status.onSessionCalleeAckNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    session_status.onSessionCalleeAckNotify.DynamicInvoke(channel_id, info.Uid, info.Type, info.Accept > 0);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeControlRes:
            {
                if (session_status.onSessionControlRes != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    session_status.onSessionControlRes.DynamicInvoke(channel_id, code, info.Type);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeControlNotify:
            {
                if (session_status.onSessionControlNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    session_status.onSessionControlNotify.DynamicInvoke(channel_id, info.Uid, info.Type);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeConnect:
            {
                if (session_status.onSessionConnectNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionConnectNotify.DynamicInvoke(channel_id, code, info.RecordAddr, info.RecordFile);
                    }
                    else
                    {
                        session_status.onSessionConnectNotify.DynamicInvoke(channel_id, code, null, null);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypePeopleStatus:
            {
                if (session_status.onSessionPeopleStatus != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    session_status.onSessionPeopleStatus.DynamicInvoke(channel_id, info.Uid, code);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeNetStatus:
            {
                if (session_status.onSessionNetStatus != null)
                {
                    session_status.onSessionNetStatus.DynamicInvoke(channel_id, code);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeHangupRes:
            {
                if (session_status.onSessionHangupRes != null)
                {
                    session_status.onSessionHangupRes.DynamicInvoke(channel_id, code);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeHangupNotify:
            {
                if (session_status.onSessionHangupNotify != null)
                {
                    session_status.onSessionHangupNotify.DynamicInvoke(channel_id, code);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeSyncAckNotify:
            {
                if (session_status.onSessionSyncAckNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    session_status.onSessionSyncAckNotify.DynamicInvoke(channel_id, code, info.Uid, info.Type, info.Accept > 0, info.Time, info.Client);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeVolumeNotify:
                if (session_status.onSessionVolumeStateChanged != null)
                {
                    var volume = NIMVchatAudioVolumeState.Deserialize(json_extension);
                    session_status.onSessionVolumeStateChanged(channel_id, code, volume);
                }
                break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeInfoNotify:
                if (session_status.onSessionRealtimeStateChanged != null)
                {
                    var state = NIMVChatRealtimeState.Deserialize(json_extension);
                    session_status.onSessionRealtimeStateChanged(channel_id, code, state);
                }
                break;
            }
        }