예제 #1
0
    void Update()
    {
        if (Time.time - curTime > 10)
        {
            client.SendMessageToAll(Encoding.UTF8.GetBytes("Hi there I'm a client"), true);
            curTime = Time.time;
        }

        client.UpdateClient();
    }
예제 #2
0
 private void Update()
 {
     isRecording = Input.GetKey(KeyCode.P);
     client.UpdateClient();
     if (client.peers.Count > 0)
     {
         while (packets.Count > 0)
         {
             float[] curPacket = packets.Dequeue();
             ToShortArray(curPacket, outBufferShort);
             int resLen = speexEnc.Encode(outBufferShort, 0, curPacket.Length, outBuffer, 0, outBuffer.Length);
             client.SendMessageToAll(outBuffer, 0, resLen, true);
         }
     }
 }
예제 #3
0
        private void Recorder_OnDataRead(float[] data, int offset, int len)
        {
            if (!isRecording)
            {
                //return;
            }
            ToShortArray(data, outBufferShort, offset, len);
            int resLen = speexEnc.Encode(outBufferShort, 0, len, outBuffer, 5, 5 * 320);

            outBuffer[0] = isSpeechId;
            outBuffer[1] = id1;
            outBuffer[2] = id2;
            outBuffer[3] = id3;
            outBuffer[4] = id4;
            client.SendMessageToAll(outBuffer, 0, resLen, true);
        }