Ejemplo n.º 1
0
        public static void PlayChat()
        {
            if (avPlayer == null)
            {
                return;
            }

            ringer.StopRinging();

            avPlayer.player.CallFunction("<invoke name=\"PlayChat\" returntype=\"xml\"></invoke>");

            state = AvChatStateE.Talking;

            if (ChatType == AvChatTypeE.Video || IsMuted)
            {
                ShowPlayer();
            }

            if (OnAvChatBegan != null)
            {
                OnAvChatBegan.Invoke(typeof(AvPlayer), new AvChatEventArgs(ChatType));
            }
        }
Ejemplo n.º 2
0
        public static void StartChat(DataTable dt)
        {
            Kv          kv = new Kv(dt);
            string      chatType;
            int         fromUserId   = kv.GetInt32("FromUserID");
            int         toUserId     = kv.GetInt32("ToUserID");
            string      fromUserName = kv.Get("FromUserName");
            AvChatTypeE chatTypeE    = (AvChatTypeE)kv.GetInt32("AvChatType");

            if (chatTypeE == AvChatTypeE.Audio)
            {
                chatType = "audio";
            }
            else
            {
                chatType = "video";
            }

            if (MessageForm.Confirm(ActiveForm, MsgE.InfoAvChatRequested, chatType, fromUserName) == DialogResult.No)
            {
                kv.Set("AvChat", (int)AvChatE.Declined);
                SocketClient.SendAvResponse(kv);
                return;
            }

            state         = AvChatStateE.Talking;
            initiatedChat = false;
            ChatType      = chatTypeE;
            FromUserId    = fromUserId;
            FromUserName  = fromUserName;
            ToUserId      = toUserId;

            if (avPlayer != null)
            {
                avPlayer.Dispose();
                avPlayer = null;
            }

            StringBuilder connectionString = new StringBuilder("rtmp://");

            connectionString.Append(Config.AvServerIp);
            connectionString.Append(":");
            connectionString.Append(Config.AvServerPort);
            connectionString.Append("/videochat");

            try
            {
                avPlayer = new AvPlayer();
                if (ChatType == AvChatTypeE.Video)
                {
                    ShowPlayer();
                }

                string chatTypeString = ((int)ChatType + 1).ToString();
                avPlayer.player.CallFunction("<invoke name=\"StartChat\" returntype=\"xml\"><arguments><string>" + connectionString.ToString() + "</string><string>" + FromUserId + "</string><string>" + ToUserId + "</string><number>" + chatTypeString + "</number></arguments></invoke>");

                if (OnAvChatBegan != null)
                {
                    OnAvChatBegan.Invoke(typeof(AvPlayer), new AvChatEventArgs(ChatType));
                }
            }

            catch (AccessViolationException ex)
            {
                TestDebugger.Instance.WriteError(ex);
                StopChat();
                MessageForm.Show(null, MsgE.ErrorAvNoCamera, MessageBoxButtons.OK, MessageBoxIcon.Error, ex);
            }
            catch (COMException e)
            {
                TestDebugger.Instance.WriteError(e);
                if (e.Message.Substring(0, 20) == "Class not registered")
                {
                    MessageForm.Show(null, MsgE.ErrorAvNoPlayer, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }