void Update() { if (Time.time - curTime > 10) { client.SendMessageToAll(Encoding.UTF8.GetBytes("Hi there I'm a client"), true); curTime = Time.time; } client.UpdateClient(); }
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); } } }
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); }