Пример #1
0
        private void SendEcho(uint number, uint timeMs)
        {
            byte[] data = new byte[BenchmarkSender.MESSAGE_SIZE_MIN];

            byte[] data1 = BitConverter.GetBytes(number);
            byte[] data2 = BitConverter.GetBytes(timeMs);
            for (int i = 0; i < 4; i++)
            {
                data[i] = data1[i];
            }
            for (int i = 0; i < 4; i++)
            {
                data[4 + i] = data2[i];
            }


            bool sent = echo.Send(data, true, mToSender);

            //might be a problem if the sender is much faster than the echo server.
            //even though the sender needs to send hundreds of times more data
            if (sent == false)
            {
                mStatDropped++;
                Debug.LogWarning("echo message dropped. Buffer full?");
            }
        }
Пример #2
0
 protected void SendMessage(byte[] bytes, bool simulateMessages = true)
 {
     caller.Send(bytes, true);
     if (Globals.simulateMessages && simulateMessages)
     {
         Globals.mainApp.SimulateMessage(bytes);
     }
 }
Пример #3
0
 public void SendMessage(byte[] bytes, bool simulate = true, float delay = 0.0f)
 {
     if (caller == null)
     {
         Globals.FatalError("server is not running");
     }
     caller.Send(bytes, true);
     if (Globals.simulateMessages && simulate)
     {
         SimulateMessage(bytes, delay);
     }
 }
        /// <summary>
        /// Sends a message to the other end
        /// </summary>
        /// <param name="msg"></param>
        private void SendMsg(string msg)
        {
            if (String.IsNullOrEmpty(msg))
            {
                //never send null or empty messages. webrtc can't deal with that
                return;
            }

            Append(msg);
            mCall.Send(msg);

            //reset UI
            uMessageField.text = "";
            uMessageField.Select();
        }
Пример #5
0
        private bool SendOneMessage()
        {
            //sanity check
            if (buffer.Length < MESSAGE_SIZE_MIN)
            {
                Debug.LogError("sender: Message size set too small!");
                return(false);
            }


            int bytesWritten = 0;

            byte[] nb = BitConverter.GetBytes(mNumberSent);
            for (int i = 0; i < 4; i++)
            {
                buffer[i] = nb[i];
            }
            bytesWritten += 4;

            int time = TimeMs;

            byte[] timeData = BitConverter.GetBytes(time);
            for (int i = 0; i < timeData.Length; i++)
            {
                buffer[bytesWritten + i] = timeData[i];
            }
            bytesWritten += bytesWritten;

            //sanity check
            if (bytesWritten > MESSAGE_SIZE_MIN)
            {
                Debug.LogError("sender: Created message too large");
                return(false);
            }
            Msg m = new Msg();

            m.number = mNumberSent;
            m.time   = time;
            mAwaitingMessage.Add(m);
            if (BenchmarkConfig.VERBOSE)
            {
                Debug.Log("sender: sent message " + m.number);
            }
            bool successful = sender.Send(buffer, SEND_RELIABLE, mToEcho);

            return(successful);
        }