Exemplo 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]);
                    }

                }

            }
        }
Exemplo n.º 2
0
        /*
          * Send a message to the remote party.
          */
        private void SendMessage(VoiceCommon.Command cmd, EndPoint sendToEP)
        {
            try
            {
                //Create the message to send.
                VoiceCommon.Data msgToSend = new VoiceCommon.Data();

                msgToSend.strName = Nickname;   //Name of the user.
                msgToSend.cmdCommand = cmd;         //Message to send.
                msgToSend.vocoder = vocoder;        //Vocoder to be used.

                byte[] message = msgToSend.ToByte();

                //Send the message asynchronously.
                clientSocket.BeginSendTo(message, 0, message.Length, SocketFlags.None, sendToEP, new AsyncCallback(OnSend), null);
            }
            catch (Exception ex)
            {
                cGlobalVars.AddLogChat("VoiceChat-SendMessage > " + ex.Message);
                //MessageBox.Show(ex.Message, "VoiceChat-SendMessage ()", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }