Ejemplo n.º 1
15
        public void ChangeCodification(VoiceCommon.Vocoder codification)
        {
            if (codification == VoiceCommon.Vocoder.ALaw)
            {
                vocoder = VoiceCommon.Vocoder.ALaw;
                cGlobalVars.AddLogChat("Se ha modificado codificación a: ALaw");
                if (eMode == Mode.Server)
                {
                    lock (clientIPs)
                    {
                        for (int i = 0; i < clientIPs.Count; i++)
                            SendMessage(VoiceCommon.Command.ChangeVocoderALaw, clientIPs[i]);
                    }

                }
            }
            else if (codification == VoiceCommon.Vocoder.uLaw)
            {
                vocoder = VoiceCommon.Vocoder.uLaw;
                cGlobalVars.AddLogChat("Se ha modificado codificación a: uLaw");

                if (eMode == Mode.Server)
                {
                    lock (clientIPs)
                    {
                        for (int i = 0; i < clientIPs.Count; i++)
                            SendMessage(VoiceCommon.Command.ChangeVocoderuLaw, clientIPs[i]);
                    }

                }

            }
            else
            {
                vocoder = VoiceCommon.Vocoder.None;
                cGlobalVars.AddLogChat("Se ha modificado codificación a: None");
                if (eMode == Mode.Server)
                {
                    lock (clientIPs)
                    {
                        for (int i = 0; i < clientIPs.Count; i++)
                            SendMessage(VoiceCommon.Command.ChangeVocoderNone, clientIPs[i]);
                    }

                }

            }
        }
Ejemplo n.º 2
0
        /*
         * Commands are received asynchronously. OnReceive is the handler for them.
         */
        private void OnReceive(IAsyncResult ar)
        {
            //TODO: Switch Receive Commands

            try
            {
                EndPoint receivedFromEP = new IPEndPoint(IPAddress.Any, 0);

                //Get the IP from where we got a message.
                clientSocket.EndReceiveFrom(ar, ref receivedFromEP);

                //Convert the bytes received into an object of type Data.
                VoiceCommon.Data msgReceived = new VoiceCommon.Data(byteData);

                //Act according to the received message.
                switch (msgReceived.cmdCommand)
                {
                //MODO SERVER: recepción de invitación por parte de cliente.
                case VoiceCommon.Command.Invite:
                {
                    if (IsServiceStarted && eMode == Mode.Server)
                    {
                        cGlobalVars.AddLogChat("Se ha conectado: " + receivedFromEP.ToString());
                        vocoder = msgReceived.vocoder;

                        lock (clientIPs)
                        {
                            if (!ExistsIp((IPEndPoint)receivedFromEP))
                            {
                                clientIPs.Add((IPEndPoint)receivedFromEP);
                            }
                        }

                        SendMessage(VoiceCommon.Command.OK, receivedFromEP);
                    }

                    break;
                }
                }

                byteData = new byte[1024];
                //Get ready to receive more commands.

                if (!bStop)
                {
                    clientSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref receivedFromEP, new AsyncCallback(OnReceive), null);
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "VoiceChat-OnReceive ()", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cGlobalVars.AddLogChat("VoiceChat-OnReceive () > " + ex.Message);
            }
        }
Ejemplo n.º 3
0
        public void ChangeCodification(VoiceCommon.Vocoder codification)
        {
            if (codification == VoiceCommon.Vocoder.ALaw)
            {
                vocoder = VoiceCommon.Vocoder.ALaw;
                cGlobalVars.AddLogChat("Se ha modificado codificación a: ALaw");
                if (eMode == Mode.Server)
                {
                    lock (clientIPs)
                    {
                        for (int i = 0; i < clientIPs.Count; i++)
                        {
                            SendMessage(VoiceCommon.Command.ChangeVocoderALaw, clientIPs[i]);
                        }
                    }
                }
            }
            else if (codification == VoiceCommon.Vocoder.uLaw)
            {
                vocoder = VoiceCommon.Vocoder.uLaw;
                cGlobalVars.AddLogChat("Se ha modificado codificación a: uLaw");

                if (eMode == Mode.Server)
                {
                    lock (clientIPs)
                    {
                        for (int i = 0; i < clientIPs.Count; i++)
                        {
                            SendMessage(VoiceCommon.Command.ChangeVocoderuLaw, clientIPs[i]);
                        }
                    }
                }
            }
            else
            {
                vocoder = VoiceCommon.Vocoder.None;
                cGlobalVars.AddLogChat("Se ha modificado codificación a: None");
                if (eMode == Mode.Server)
                {
                    lock (clientIPs)
                    {
                        for (int i = 0; i < clientIPs.Count; i++)
                        {
                            SendMessage(VoiceCommon.Command.ChangeVocoderNone, clientIPs[i]);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public void ChangeCodification(VoiceChat.Library.Common.VoiceCommon.Vocoder codification)
 {
     if (codification == VoiceCommon.Vocoder.ALaw)
     {
         vocoder = VoiceCommon.Vocoder.ALaw;
         cGlobalVars.AddLogChat("Se ha modificado codificación a: ALaw");
     }
     else if (codification == VoiceCommon.Vocoder.uLaw)
     {
         vocoder = VoiceCommon.Vocoder.uLaw;
         cGlobalVars.AddLogChat("Se ha modificado codificación a: uLaw");
     }
     else
     {
         vocoder = VoiceCommon.Vocoder.None;
         cGlobalVars.AddLogChat("Se ha modificado codificación a: None");
     }
 }
Ejemplo n.º 5
0
        /*
        * Commands are received asynchronously. OnReceive is the handler for them.
        */
        private void OnReceive(IAsyncResult ar)
        {
            //TODO: Switch Receive Commands

            try
            {

                EndPoint receivedFromEP = new IPEndPoint(IPAddress.Any, 0);

                //Get the IP from where we got a message.
                clientSocket.EndReceiveFrom(ar, ref receivedFromEP);

                //Convert the bytes received into an object of type Data.
                VoiceCommon.Data msgReceived = new VoiceCommon.Data(byteData);

                //Act according to the received message.
                switch (msgReceived.cmdCommand)
                {

                    //MODO SERVER: recepción de invitación por parte de cliente.
                    case VoiceCommon.Command.Invite:
                        {
                            if (IsServiceStarted && eMode == Mode.Server)
                            {

                                cGlobalVars.AddLogChat("Se ha conectado: " + receivedFromEP.ToString());
                                vocoder = msgReceived.vocoder;

                                lock (clientIPs)
                                {
                                    if (!ExistsIp((IPEndPoint)receivedFromEP))
                                        clientIPs.Add((IPEndPoint)receivedFromEP);
                                }

                                SendMessage(VoiceCommon.Command.OK, receivedFromEP);

                            }

                            break;
                        }

                }

                byteData = new byte[1024];
                //Get ready to receive more commands.

                if (!bStop)
                    clientSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref receivedFromEP, new AsyncCallback(OnReceive), null);

            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "VoiceChat-OnReceive ()", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cGlobalVars.AddLogChat("VoiceChat-OnReceive () > " + ex.Message);
            }
        }
Ejemplo n.º 6
0
        public void ChangeCodification(VoiceChat.Library.Common.VoiceCommon.Vocoder codification)
        {
            if (codification == VoiceCommon.Vocoder.ALaw)
            {
                vocoder = VoiceCommon.Vocoder.ALaw;
                cGlobalVars.AddLogChat("Se ha modificado codificación a: ALaw");

            }
            else if (codification == VoiceCommon.Vocoder.uLaw)
            {
                vocoder = VoiceCommon.Vocoder.uLaw;
                cGlobalVars.AddLogChat("Se ha modificado codificación a: uLaw");

            }
            else
            {
                vocoder = VoiceCommon.Vocoder.None;
                cGlobalVars.AddLogChat("Se ha modificado codificación a: None");

            }
        }