// 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(outlet);
             initialised = true;
             Debug.Log("Successfully Initialised Presentation Board");
         } catch (NullReferenceException ex) {
         }
     }
     else
     {
         if (!outlet.IsOutletEmpty())
         {
             Message m = outlet.GetNextMessage();
             if (m.Signal == "CHNG")
             {
                 ByteBuffer buffer = new ByteBuffer(m.Payload);
                 currentSlideNumber = buffer.ReadInt();                     //The only way the current slide number changes is if a CHNG message is received
                 FixSlideNumber();
                 meetingDisplay.SetCurrentSlideNumber(currentSlideNumber);
                 StartCoroutine(ChangeImage());                     //The only way the image on the board will change is if a CHNG message is received
             }
         }
     }
 }
    // 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(outlet);

                initialised = true;
                Debug.Log("Successfully Initialised Player Manager");
                Message ma = new Message("GAP", new byte[0]);
                socket.sendMessage(ma);
            } catch (NullReferenceException ex) {
            }
        }
        else
        {
            if (!outlet.IsOutletEmpty())
            {
                Message m = outlet.GetNextMessage();

                if (m.Signal.Equals(ServerSignals.LEFT.ToString()))
                {
                    int  userID = BitConverter.ToInt32(m.Payload, 0);
                    User user   = GetUser(userID);

                    if (user != null)
                    {
                        Debug.Log("User " + user.userID + ":" + user.firstName + " has left");
                        RemoveUser(userID);
                    }
                }
                else if (m.Signal.Equals(ServerSignals.UDM.ToString()))
                {
                    string userInfo = System.Text.ASCIIEncoding.ASCII.GetString(m.Payload);
                    User   user     = JsonUtility.FromJson <User> (userInfo);

                    if (user.presenting)
                    {
                        meetingDisplay.SetPresenterName(user.firstName);
                    }

                    if (user.userID == ReadFile.getUserID())
                    {
                        Configuration.Config.isClientPresenter = user.presenting;
                        button1.SetActive(user.presenting);
                        button2.SetActive(user.presenting);
                        presenterScript.enabled   = user.presenting;
                        participantScript.enabled = !user.presenting;
                    }

                    AddUser(user);
                }
            }
        }
    }
Esempio n. 3
0
    // 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;
                ClientSocket socket       = socketScript.getSocket();
                socket.registerObserver(messageOutlet);
                initialised = true;
                Debug.Log("Successfully Initialised New Avatar");
            }
            catch (NullReferenceException ex)
            {
            }
        }
        else
        {
            //Debug.Log("In else statement");
            if (messageOutlet != null)
            {
                if (!messageOutlet.IsOutletEmpty())
                {
                    Message m = messageOutlet.GetNextMessage();
                    Debug.Log("signal:" + m.Signal);
                    if (m.Signal == "UDM")
                    {
                        ByteBuffer bf1      = new ByteBuffer(m.Payload);
                        String     userData = bf1.ReadString(m.Payload.Length);

                        dataField userInfo    = JsonUtility.FromJson <dataField>(userData);
                        String    userID      = userInfo.userID;
                        String    firstName   = userInfo.firstName;
                        String    surName     = userInfo.surName;
                        String    Company     = userInfo.Company;
                        String    jobTitle    = userInfo.jobTitle;
                        String    workEmail   = userInfo.workEmail;
                        String    phoneNumber = userInfo.phoneNumber;
                        String    avatarID    = userInfo.avatarID;

                        int id;
                        int.TryParse(avatarID, out id);

                        Debug.Log("Avatar ID:" + id);
                        DisplayAvatar(id);
                    }
                }
            }
        }
    }
Esempio n. 4
0
 // 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();
             initialised = true;
             Debug.Log("Successfully Initialised LeaveButton");
         } catch (NullReferenceException ex) {
         }
     }
 }
    // Use this for initialization
    void Start()
    {
        clip = Microphone.Start(null, true, Config.CAPTURE_LENGTH, Config.MIC_SAMPLE_FREQUENCY);
        while (!(Microphone.GetPosition(null) > 0))
        {
        }
        //Debug.Log("start playing... position is " + Microphone.GetPosition(null));
        GameObject camera       = GameObject.FindGameObjectsWithTag("MainCamera")[0];
        TestSocket socketScript = camera.GetComponent(typeof(TestSocket)) as TestSocket;

        socket = socketScript.getSocket();
        Debug.Log("Obtained socket");
        InvokeRepeating("SendNextClip", Config.CAPTURE_LENGTH, Config.CAPTURE_LENGTH);
    }
    // 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));
                        }
                    }
                }
            }
        }
    }