Exemplo n.º 1
0
        private void AvChatUc_OnDial(object sender, AvChatEventArgs args)
        {
            if (chatType == ChatTypeE.OnlineClient)
            {
                if (cbAudienceType.SelectedIndex < 2 || UserID == Ap.CurrentUserID)
                {
                    return;
                }
            }
            else if (cbAudienceType.SelectedIndex != 0)
            {
                return;
            }

            if (Ap.CurrentUser.IsGuest || UserRank == "Guest")
            {
                ChatClient.Write(chatType, ChatMessageTypeE.Warning, chatType, "Not allowed for guest", 0);
                return;
            }

            if (!AvPlayer.IsFlash8Installed())
            {
                if (MessageForm.Confirm(this.ParentForm, MsgE.ConfirmFlashInstall) == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(Msg.GetMsg(MsgE.InfoFlashUrl));
                }
                return;
            }

            ChatMessageEventArgs chatMessage = new ChatMessageEventArgs();

            chatMessage.ChatType = chatType;
            chatMessage.Type     = ChatMessageTypeE.Inprogress;
            //chatMessage.Message = "Calling " + UserName + "...";
            chatMessage.Message = "Connecting to chat server" + "...";
            AddLine(chatMessage);
            AvPlayer.InitializeChat(UserID, UserName, args.ChatType, chatType);
        }
Exemplo 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);
                }
            }
        }