예제 #1
0
 public static string ExecuteInstructions(string instructionString) {
     var testSocket = new TestSocket(string.Format("{0:000000}:{1}", instructionString.Length, instructionString));
     var messenger = new Messenger(testSocket);
     var interpreter = new Interpreter(messenger, string.Empty, Builder.Service());
     interpreter.ProcessInstructions();
     return testSocket.Output;
 }
    // Update is called once per frame
    void Update()
    {
        if (!initialised)
        {
            try {
                GameObject camera       = GameObject.FindGameObjectsWithTag("MainCamera") [0];
                TestSocket socketScript = camera.GetComponent(typeof(TestSocket)) as TestSocket;
                socket = socketScript.getSocket();
                socket.registerObserver(presenterAudioOutlet);
                initialised = true;
                //Debug.Log("Successfully Initialised Meeting Participant Script");
            } catch (NullReferenceException ex) {
            }
        }
        else
        {
            if (!presenterAudioOutlet.IsOutletEmpty())                 //Whenever you receive a message
            {
                Message next = presenterAudioOutlet.GetNextMessage();  //Get that message

                if (next.Signal.Equals(ServerSignals.AUDI.ToString())) //Add the payload to the buffer of data for the next audio sample
                {
                    payloadBuffer.Add(next.Payload);
                }
                else if (next.Signal.Equals(ServerSignals.EAUD.ToString()))                       //Take all of the payloads obtained until this point and append them to make 1 byte[] then decompress the array and convert it to an audio clip
                {
                    ByteBuffer combinedPayload = new ByteBuffer();
                    //Debug.Log ("Received full audio clip. It took " + payloadBuffer.Count + " messages to receive the audio");

                    foreach (byte[] currentPayload in payloadBuffer)
                    {
                        combinedPayload.WriteBytes(currentPayload);
                    }
                    payloadBuffer.Clear();


                    int originalDataLength = BitConverter.ToInt32(next.Payload, 0);

//					DecompressAndStore (new CompressedData (combinedPayload.ToBytes (), originalDataLength));
                    Thread decompressThread = new Thread(DecompressAndStore);
                    Debug.Log("Decompressing " + combinedPayload.ToBytes().Length + " bytes");
                    decompressThread.Start(new CompressedData(combinedPayload.ToBytes(), originalDataLength));
                }
            }

            if (canOutput)                         //If the initial 15 seconds has passed
            {
                if (Time.time >= playNextSampleAt) // If it's time to play the next sample i.e the time since the last sample has started + it's length has elapsed
                {
                    if (!IsClipQueueEmpty())       //If there's a full clip to play
                    {
                        //Debug.Log("Playing audio");
                        AudioClip nextClip = GetNextClipInQueue();
                        if (nextClip != null)
                        {
                            //Debug.Log("Playing audio clip that is " + nextClip.length + " seconds long");
                            lastSampleStartedAt = Time.time;
                            playNextSampleAt    = Time.time + nextClip.length;
                            AudioSource.PlayClipAtPoint(nextClip, new Vector3(0, 0, 0));
                        }
                    }
                }
            }
        }
    }
예제 #3
0
 public void SetUp()
 {
     socket    = new TestSocket();
     messenger = new Messenger(socket);
     socket.Clear();
 }
예제 #4
0
 public void WritesVersion()
 {
     socket    = new TestSocket();
     messenger = new Messenger(socket);
     Assert.AreEqual("Slim -- V0.4\n", socket.GetByteString());
 }