Пример #1
0
        //-----------------------------------------------------------------------------
        // message aggregation
        //-----------------------------------------------------------------------------

        public List <ViveShareMessage> GenerateMessagesList()
        {
            List <ViveShareMessage> list = new List <ViveShareMessage>();

            // dump message from queue
            while (messageQueue.Count > 0)
            {
                ViveShareMessage msg = messageQueue.Dequeue();
                list.Add(msg);
            }

            // append sync param information to list
            for (int i = 0; i < syncIdList.Count; i++)
            {
                if (syncIdList[i].hasAuthority == false)
                {
                    continue;
                }

                ViveShareMessage   msg;
                ViveShare_SyncBase syncObj = GetSyncObjFromSyncId(syncIdList[i]);
                if (syncObj != null && syncObj.GenerateMessage(out msg))
                {
                    list.Add(msg);
                }
            }

            return(list);
        }
Пример #2
0
        public void AddDespawnMessage(string objID)
        {
            ViveShareMessage viveMsg = new ViveShareMessage();

            viveMsg.type = ViveShareMsgType.UnSpawn;
            viveMsg.body = new StringMessage(objID);

            messageQueue.Enqueue(viveMsg);
        }
Пример #3
0
        //-----------------------------------------------------------------------------
        // networked operation
        //-----------------------------------------------------------------------------

        public void AddEventMessage(string eventID, object[] args)
        {
            ViveShare_ParamMessage eventMsg = new ViveShare_ParamMessage();

            eventMsg.id        = eventID;
            eventMsg.timeStamp = Time.time;
            eventMsg.objects   = args;

            ViveShareMessage msg = new ViveShareMessage();

            msg.type = ViveShareMsgType.Event;
            msg.body = eventMsg;

            messageQueue.Enqueue(msg);
        }
Пример #4
0
        public void AddSpawnMessage(string assetName, string objID, Vector3 position, Quaternion rotation)
        {
            ViveNetworkSpawnMessage spawnMsg = new ViveNetworkSpawnMessage();

            spawnMsg.assetName     = assetName;
            spawnMsg.objectID      = objID;
            spawnMsg.position      = position;
            spawnMsg.eulerRotation = rotation.eulerAngles;

            ViveShareMessage viveMsg = new ViveShareMessage();

            viveMsg.type = ViveShareMsgType.Spawn;
            viveMsg.body = spawnMsg;

            messageQueue.Enqueue(viveMsg);
        }
Пример #5
0
        //-----------------------------------------------------------------------------
        // network message
        //-----------------------------------------------------------------------------

        public bool GenerateMessage(out ViveShareMessage outMsg)
        {
            outMsg = null;

            if (identity.hasAuthority && (Time.time - lastSendTime > sendInterval))
            {
                object[] paramList = GenerateParamList();

                ViveShare_ParamMessage paramMsg = new ViveShare_ParamMessage();
                paramMsg.id        = identity.id;
                paramMsg.timeStamp = Time.time;
                paramMsg.objects   = paramList;

                outMsg      = new ViveShareMessage();
                outMsg.type = ViveShareMsgType.SyncParam;
                outMsg.body = paramMsg;

                lastSendTime = Time.time;
                return(true);
            }

            return(false);
        }