Exemple #1
0
        public void SendAddObjectToColleciton(AddToCollectionInfo addToCollectionInfo)
        {
            string collectionName = addToCollectionInfo.collectionName;

            if (!SyncData.collectionNodes.ContainsKey(collectionName))
            {
                NetCommand addCollectionCommand = MixerUtils.BuildAddCollecitonCommand(collectionName);
                AddCommand(addCollectionCommand);
            }

            NetCommand commandAddObjectToCollection = MixerUtils.BuildAddObjectToCollecitonCommand(addToCollectionInfo);

            AddCommand(commandAddObjectToCollection);
            if (!SyncData.sceneCollections.Contains(collectionName))
            {
                NetCommand commandAddCollectionToScene = MixerUtils.BuildAddCollectionToScene(collectionName);
                AddCommand(commandAddCollectionToScene);
            }
        }
Exemple #2
0
        void Run()
        {
            while (alive)
            {
                NetCommand command = ReadMessage();
                if (command != null)
                {
                    if (command.messageType == MessageType.ClientId ||
                        command.messageType == MessageType.ClientUpdate ||
                        command.messageType == MessageType.ListAllClients ||
                        command.messageType > MessageType.Command)
                    {
                        lock (this)
                        {
                            if (command.messageType == MessageType.ClientIdWrapper)
                            {
                                UnpackFromClientId(command, ref receivedCommands);
                            }
                            else
                            {
                                receivedCommands.Add(command);
                            }
                        }
                    }
                }

                lock (this)
                {
                    if (pendingCommands.Count > 0)
                    {
                        foreach (NetCommand pendingCommand in pendingCommands)
                        {
                            WriteMessage(pendingCommand);
                        }
                        pendingCommands.Clear();
                    }
                }
            }
        }
Exemple #3
0
        public void JoinRoom(string roomName)
        {
            byte[] nameBuffer         = Converter.StringToBytes(roomName);
            byte[] mockVersionBuffer  = Converter.StringToBytes("ignored");
            byte[] versionCheckBuffer = Converter.BoolToBytes(true);
            byte[] buffer             = Converter.ConcatenateBuffers(new List <byte[]> {
                nameBuffer, mockVersionBuffer, mockVersionBuffer, versionCheckBuffer
            });
            NetCommand command = new NetCommand(buffer, MessageType.JoinRoom);

            AddCommand(command);

            string json = VRtistMixer.CreateClientNameAndColor();

            if (null == json)
            {
                return;
            }
            NetCommand commandClientInfo = new NetCommand(Converter.StringToBytes(json), MessageType.SetClientCustomAttribute);

            AddCommand(commandClientInfo);
        }
Exemple #4
0
        public bool UnpackFromClientId(NetCommand command, ref List <NetCommand> commands)
        {
            int    index    = 0;
            string masterId = Converter.GetString(command.data, ref index);

            // For debug purpose (unity in editor mode when networkSettings.master is empty)
            string currentMasterId = VRtistMixer.GetMasterId();

            if (null == currentMasterId || currentMasterId.Length == 0)
            {
                VRtistMixer.SetMasterId(masterId);
            }

            if (masterId != VRtistMixer.GetMasterId())
            {
                return(false);
            }

            int remainingData = command.data.Length - index;

            while (remainingData > 0)
            {
                int dataLength = Converter.GetInt(command.data, ref index);
                remainingData -= dataLength + sizeof(int);

                dataLength -= sizeof(int);
                int    messageType = Converter.GetInt(command.data, ref index);
                byte[] newBuffer   = new byte[dataLength];

                Buffer.BlockCopy(command.data, index, newBuffer, 0, dataLength);
                index += dataLength;

                NetCommand newCommand = new NetCommand(newBuffer, (MessageType)messageType);
                commands.Add(newCommand);
            }

            return(true);
        }
Exemple #5
0
        public void SendDuplicate(DuplicateInfos duplicate)
        {
            NetCommand command = MixerUtils.BuildDuplicateCommand(root, duplicate);

            AddCommand(command);
        }
Exemple #6
0
        public void SendToTrash(SendToTrashInfo sendToTrash)
        {
            NetCommand command = MixerUtils.BuildSendToTrashCommand(root, sendToTrash);

            AddCommand(command);
        }
Exemple #7
0
        public void SendMaterial(Material material)
        {
            NetCommand command = MixerUtils.BuildMaterialCommand(material);

            AddCommand(command);
        }
Exemple #8
0
        public void SendQueryObjectData(string name)
        {
            NetCommand command = MixerUtils.BuildSendQueryAnimationData(name);

            AddCommand(command);
        }
Exemple #9
0
        public void SendShotManagerAction(ShotManagerActionInfo info)
        {
            NetCommand command = MixerUtils.BuildSendShotManagerAction(info);

            AddCommand(command);
        }
Exemple #10
0
        public void SendBlenderSave()
        {
            NetCommand command = MixerUtils.BuildSendBlenderSave();

            AddCommand(command);
        }
Exemple #11
0
        public void SendSky(SkySettings skyInfo)
        {
            NetCommand command = MixerUtils.BuildSkyCommand(skyInfo);

            AddCommand(command);
        }
Exemple #12
0
        public void SendAddObjectToScene(AddObjectToSceneInfo addObjectToScene)
        {
            NetCommand command = MixerUtils.BuildAddObjectToScene(addObjectToScene);

            AddCommand(command);
        }
Exemple #13
0
        public void SendCamera(CameraInfo cameraInfo)
        {
            NetCommand command = MixerUtils.BuildCameraCommand(root, cameraInfo);

            AddCommand(command);
        }
Exemple #14
0
        public void SendLight(LightInfo lightInfo)
        {
            NetCommand command = MixerUtils.BuildLightCommand(root, lightInfo);

            AddCommand(command);
        }
Exemple #15
0
        public void SendAddLookAtConstraint(GameObject gobject, GameObject target)
        {
            NetCommand command = MixerUtils.BuildSendAddLookAtConstraintCommand(gobject, target);

            AddCommand(command);
        }
Exemple #16
0
        public void SendEmpty(Transform transform)
        {
            NetCommand command = MixerUtils.BuildEmptyCommand(root, transform);

            AddCommand(command);
        }
Exemple #17
0
        public void SendAssignMaterial(AssignMaterialInfo info)
        {
            NetCommand command = MixerUtils.BuildAssignMaterialCommand(info);

            AddCommand(command);
        }
Exemple #18
0
        public void RestoreFromTrash(RestoreFromTrashInfo restoreFromTrash)
        {
            NetCommand command = MixerUtils.BuildRestoreFromTrashCommand(root, restoreFromTrash);

            AddCommand(command);
        }
Exemple #19
0
        public void SendRename(RenameInfo rename)
        {
            NetCommand command = MixerUtils.BuildRenameCommand(root, rename);

            AddCommand(command);
        }
Exemple #20
0
        public void SendTransform(Transform transform)
        {
            NetCommand command = MixerUtils.BuildTransformCommand(transform);

            AddCommand(command);
        }
Exemple #21
0
        public void SendMesh(MeshInfos meshInfos)
        {
            NetCommand command = MixerUtils.BuildMeshCommand(root, meshInfos);

            AddCommand(command);
        }
Exemple #22
0
        public void SendClearAnimations(ClearAnimationInfo info)
        {
            NetCommand command = MixerUtils.BuildSendClearAnimations(info);

            AddCommand(command);
        }
Exemple #23
0
        public void SendObjectVisibility(Transform transform)
        {
            NetCommand command = MixerUtils.BuildObjectVisibilityCommand(transform);

            AddCommand(command);
        }
Exemple #24
0
        public void SendBlenderBank(BlenderBankInfo info)
        {
            NetCommand command = MixerUtils.BuildSendBlenderBank(info);

            AddCommand(command);
        }
Exemple #25
0
        public void SendMoveKeyframe(MoveKeyInfo data)
        {
            NetCommand command = MixerUtils.BuildSendMoveKey(data);

            AddCommand(command);
        }
Exemple #26
0
        public void SendFrameStartEnd(FrameStartEnd range)
        {
            NetCommand command = MixerUtils.BuildSendFrameStartEndCommand(range.start, range.end);

            AddCommand(command);
        }
Exemple #27
0
        public void SendDelete(DeleteInfo deleteInfo)
        {
            NetCommand command = MixerUtils.BuildDeleteCommand(root, deleteInfo);

            AddCommand(command);
        }
Exemple #28
0
        public void SendAnimationCurve(CurveInfo data)
        {
            NetCommand command = MixerUtils.BuildSendAnimationCurve(data);

            AddCommand(command);
        }
Exemple #29
0
        public void Connect()
        {
            connected = false;
            string[] args = System.Environment.GetCommandLineArgs();
#if UNITY_EDITOR
            // For debug purpose use the network settings
            VRtistMixer.GetNetworkData(ref hostname, ref room, ref port, ref master, ref userName, ref userColor);
#else
            hostname = null;
#endif

            // Read command line
            for (int i = 0; i < args.Length; i++)
            {
                if (args[i] == "--room")
                {
                    room = args[i + 1];
                }
                if (args[i] == "--hostname")
                {
                    hostname = args[i + 1];
                }
                if (args[i] == "--port")
                {
                    Int32.TryParse(args[i + 1], out port);
                }
                if (args[i] == "--master")
                {
                    master = args[i + 1];
                }
                if (args[i] == "--username")
                {
                    userName = args[i + 1];
                }
                if (args[i] == "--usercolor")
                {
                    ColorUtility.TryParseHtmlString(args[i + 1], out userColor);
                }
            }

#if UNITY_EDITOR
            VRtistMixer.SetNetworkData(room, master, userName, userColor);
#endif

            if (null == hostname)
            {
                return;
            }

            IPAddress ipAddress = GetIpAddressFromHostname(hostname);
            if (null == ipAddress)
            {
                return;
            }

            IPEndPoint remoteEP = new IPEndPoint(ipAddress, port);

            // Create a TCP/IP  socket.
            socket = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

            // Connect the socket to the remote endpoint. Catch any errors.
            try
            {
                socket.Connect(remoteEP);
            }
            catch (ArgumentNullException ane)
            {
                Console.WriteLine("ArgumentNullException : {0}", ane.ToString());
                return;
            }
            catch (SocketException se)
            {
                Console.WriteLine("SocketException : {0}", se.ToString());
                return;
            }
            catch (Exception e)
            {
                Console.WriteLine("Unexpected exception : {0}", e.ToString());
                return;
            }

            JoinRoom(room);
            connected = true;

            NetCommand command = new NetCommand(new byte[0], MessageType.ClientId);
            AddCommand(command);

            NetCommand commandListClients = new NetCommand(new byte[0], MessageType.ListAllClients);
            AddCommand(commandListClients);

            thread = new Thread(new ThreadStart(Run));
            thread.Start();
        }