Exemplo n.º 1
0
        private void PostMessage(string message)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new Action <string>(PostMessage), new object[] { message });
            }
            else
            {
                try
                {
                    //httpProxy.Transmit("#videochat#*"+username+"*"+ myListeningUrl+"*"+videoport+"*"+auport);
                    string[] splitmessage = message.Split('*');
                    if (splitmessage[0] == "#videochat#")
                    {
                        ringing.PlayLooping();
                        vclient_ipaddress = splitmessage[2];
                        vclient_name      = splitmessage[1];
                        client_videoport  = splitmessage[3];
                        client_auport     = splitmessage[4];
                        videoflag         = true;
                        DialogResult result =
                            MessageBox.Show("Video request from " + vclient_name + ", accept or decline?",
                                            "Video Request", MessageBoxButtons.OK);

                        this.AdjustUi();
                    }
                    else if (splitmessage[0] == "#acceptance#")
                    {
                        ringing.Stop();
                        client_videoport = splitmessage[1];
                        client_auport    = splitmessage[2];
                        Video_but.Text   = "Video Chat";

                        videoroom = new video_chat_room(myListeningUrl, videoport, auport, vclient_name, vclient_ipaddress, client_videoport, client_auport, camname, audioinputname, "");
                        videoroom.Show();
                    }
                    else if (splitmessage[0] == "#decline#")
                    {
                        vclient_ipaddress = "";
                        vclient_name      = "";
                        client_videoport  = "";
                        client_auport     = "";
                        videoflag         = false;
                        ringing.Stop();
                        Video_but.Text = "Video Chat";
                        this.AdjustUi();
                    }
                    else
                    {
                        this.lblChat.Text = string.Format("({0}) {1}\n", DateTime.Now.ToLongTimeString(),
                                                          message) + this.lblChat.Text;
                    }
                }

                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }
        }
Exemplo n.º 2
0
        private void accept_button_Click(object sender, EventArgs e)
        {
            auport    = (int.Parse(client_auport) % 999 + 555).ToString();
            videoport = (int.Parse(client_videoport) % 999 + 555).ToString();
            this.txtIpAddress.Text = videoport;
            this.audio_port.Text   = auport;
            this.SendingFactories  = new List <ChannelFactory <IVeryBasicCommunicationService> >();
            this.SendingFactories.Add(new ChannelFactory <IVeryBasicCommunicationService>(new BasicHttpBinding(),
                                                                                          new EndpointAddress(string.Format("http://{0}/Chat", vclient_ipaddress))));
            IVeryBasicCommunicationService httpProxy = SendingFactories[0].CreateChannel();

            httpProxy.Transmit("#acceptance#*" + videoport + "*" + auport);
            videoflag = false;
            ringing.Stop();
            this.AdjustUi();
            camname        = (string)cbCameras.SelectedItem;
            audioinputname = cmbInputs.SelectedIndex.ToString();
            //video_chat_room(string myListening, string videop, string aup, string vclient_n, string vclient_ipadd, string client_videop, string client_aup, string camn, string audioinputn, string audiooutputn)
            videoroom = new video_chat_room(myListeningUrl, videoport, auport, vclient_name, vclient_ipaddress, client_videoport, client_auport, camname, audioinputname, "");
            videoroom.Show();
        }