Beispiel #1
0
    // Use this for initialization
    IEnumerator Start()
    {
        yield return(StartCoroutine(ConnectWebsocket()));

        w.Send("{ \"username\":\"" + SystemInfo.deviceUniqueIdentifier + "\"}");
        while (socketError == null)
        {
            lock (updateLock) {
                if (mocapMsg != null)
                {
                    if (OnMocapMsg != null)
                    {
                        OnMocapMsg(mocapMsg);
                    }
                    Google.Protobuf.Collections.MapField <string, Google.Protobuf.VRCom.MocapSubject> subjects = mocapMsg.Mocap.Subjects;
                    foreach (KeyValuePair <string, MocapHandler> pair in mocapHandlers)
                    {
                        if (subjects.ContainsKey(pair.Key))
                        {
                            mocapHandlers [pair.Key] (subjects [pair.Key]);
                        }
                    }
                    mocapMsg = null;
                }
                if (hydraMsg != null)
                {
                    if (OnHydraMsg != null)
                    {
                        OnHydraMsg(hydraMsg);
                    }
                    hydraMsg = null;
                }
                while (wiimoteMsgs.Count != 0)
                {
                    currMsg = wiimoteMsgs.Dequeue();
                    if (OnWiimoteMsg != null)
                    {
                        OnWiimoteMsg(currMsg);
                    }
                }
            }
            yield return(0);
        }
        Debug.LogError("Error: " + socketError);
        w.Close();
    }