Beispiel #1
0
 public void InitSender(IntPtr intptr)  // 初始化傳送聲音者
 {
     voicereceiver = new VoiceRecorder();
     voicereceiver.client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
     voicereceiver.intptr = intptr;
     voicereceiver.InitiDevice(1);
 }
Beispiel #2
0
 public void InitReceiver(IntPtr intptr, int radius)  // 初始化接收聲音者
 {
     aoi_radius = radius;
     voicereceiver = new VoiceRecorder();
     voicereceiver.intptr = intptr;
     voicereceiver.InitiDevice(2);
 }
Beispiel #3
0
 public void SelfInnformation_Print(Point center, int sp_ca, int max_sp_ca, int oh_ca, int max_oh_ca, string selfsocketip, Node listener, VoiceRecorder MIC)  // 把自己的資訊印出來
 {
     SelfInformation.Text = "OriginID : " + Vast.VASTGetSelfID().ToString()
                          + "  x : " + center.X.ToString()
                          + "  y : " + center.Y.ToString()
                          + "  Listen Capacity : " + sp_ca.ToString() + " / " + max_sp_ca.ToString()
                          + "  Overheaer Capacity : " + oh_ca.ToString() + " / " + max_oh_ca.ToString()
                          + "\n"
                          + "IP : " + selfsocketip;
     if (listener != null)
         SelfInformation.Text += "  Listener : " + listener.name.ToString();
     else
         SelfInformation.Text += "  Listener : 0";
     if (MIC != null)
         SelfInformation.Text += "  MIC : ON";
     else
         SelfInformation.Text += "  MIC : OFF";
 }
Beispiel #4
0
        private void Key_Down(object sender, KeyEventArgs e)                    // 只有輸入 enter 鍵 及 backspace 鍵 及 上下左右移動鍵 及 F1鍵時會進來  (處理功能鍵)
        {
            if (e.KeyCode.Equals(Keys.Left) || e.KeyCode.Equals(Keys.Right) || e.KeyCode.Equals(Keys.Down) || e.KeyCode.Equals(Keys.Up) ||
                e.KeyCode.Equals(Keys.End) || e.KeyCode.Equals(Keys.Home) || e.KeyCode.Equals(Keys.PageDown) || e.KeyCode.Equals(Keys.PageUp))
                GetMovements(e);
            else if (e.KeyCode.Equals(Keys.Back))  // 倒退鍵
            {
                if (input.Length > 0)  // 若還有字元就刪除
                    input = input.Remove(input.Length - 1);
                keyin.Text = input;  // 重新顯示在視窗上
            }
            else if (e.KeyCode.Equals(Keys.Enter))  // 輸入鍵
            {
                int len = SelfID.ToString().Length + TYPE_TEXT.ToString().Length + 2;  // 加 2 為 兩格空格 ID + 資料型態的長度字串
                Vast.VASTPublish((SelfID.ToString() + " " + TYPE_TEXT.ToString() + " " + input), (uint)(input.Length + len), AOI_RADIUS);  // 傳送訊息給 aoi 範圍裡的人  +2 因為前面的辨試的關係 
                show.Output_Monitor(input);
                keyin.Text = input = "[" + SelfName + "] : ";  // 清除輸入文字的區塊
            }
            else if (e.KeyCode.Equals(Keys.F1))  // F1 鍵
            {
                // 初始化錄音部份
                if (voicerecorder == null)
                {
                    voicerecorder = new VoiceRecorder();
                    voicerecorder.intptr = this.Handle;
                    voicerecorder.InitiDevice(MIC_SPEAK);  // 初始化 recorder
                    voicerecorder.Update_Info(neighborList);  // 把鄰居資訊丟進去
                    voicerecorder.StartVoiceCapture();
                }
            }
            else if (e.KeyCode.Equals(Keys.F2))  // F2 鍵為關閉語音送收訊息
            {
                if (voicerecorder != null)
                {
                    voicerecorder.Stoprec();
                    voicerecorder = null;
                }
            }
            else if (e.KeyCode.Equals(Keys.F3))
            {
                for (int i = 0; i < neighborList.Count; i++)
                {
                    Console.WriteLine(neighborList[i].name + " " + neighborList[i].socketip + " " + neighborList[i].socketport);
                }

                Console.WriteLine("server numbers : " + listenserverlist.Count);
            }
            else if (e.KeyCode.Equals(Keys.F7))  // 測試 voice thread
            {
                foreach (Node n in neighborList)
                    Console.WriteLine("id : " + n.id + " distance : " + n.distance);
                foreach (Relation r in relationList)
                    Console.WriteLine("id : " + r.id + " relation : " + r.relationship);
                Console.WriteLine(Listener.id);
            }
            else if (e.KeyCode.Equals(Keys.F8))
            {
                Console.WriteLine( Vast.VASTGetLayer());
            }
            else if (e.KeyCode.Equals(Keys.F9))
            {
                Vast.VASTReserveLayer(1);
            }
            else if (e.KeyCode.Equals(Keys.F11))  // 用來選擇 Listener
            {
                Listener New_Select_Speak = new Listener(this);
                New_Select_Speak.ShowDialog(this);  // 強制回應視窗
                myPanel.Refresh();
            }
            else if (e.KeyCode.Equals(Keys.F12))  // 用來調整想上傳之頻寬
            {
                Channel New_Channel_Select = new Channel(this);
                New_Channel_Select.ShowDialog(this);
            }
            // 顯示在視窗上
            show.SelfInnformation_Print(aoi_center, Speaker_Capacity, Max_Speaker_Capacity, Overhearer_Capacity, Max_Overhearer_capacity, socketip, Listener, voicerecorder);
        }