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); } }
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(); } } } }
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); }
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); }
public void SendDuplicate(DuplicateInfos duplicate) { NetCommand command = MixerUtils.BuildDuplicateCommand(root, duplicate); AddCommand(command); }
public void SendToTrash(SendToTrashInfo sendToTrash) { NetCommand command = MixerUtils.BuildSendToTrashCommand(root, sendToTrash); AddCommand(command); }
public void SendMaterial(Material material) { NetCommand command = MixerUtils.BuildMaterialCommand(material); AddCommand(command); }
public void SendQueryObjectData(string name) { NetCommand command = MixerUtils.BuildSendQueryAnimationData(name); AddCommand(command); }
public void SendShotManagerAction(ShotManagerActionInfo info) { NetCommand command = MixerUtils.BuildSendShotManagerAction(info); AddCommand(command); }
public void SendBlenderSave() { NetCommand command = MixerUtils.BuildSendBlenderSave(); AddCommand(command); }
public void SendSky(SkySettings skyInfo) { NetCommand command = MixerUtils.BuildSkyCommand(skyInfo); AddCommand(command); }
public void SendAddObjectToScene(AddObjectToSceneInfo addObjectToScene) { NetCommand command = MixerUtils.BuildAddObjectToScene(addObjectToScene); AddCommand(command); }
public void SendCamera(CameraInfo cameraInfo) { NetCommand command = MixerUtils.BuildCameraCommand(root, cameraInfo); AddCommand(command); }
public void SendLight(LightInfo lightInfo) { NetCommand command = MixerUtils.BuildLightCommand(root, lightInfo); AddCommand(command); }
public void SendAddLookAtConstraint(GameObject gobject, GameObject target) { NetCommand command = MixerUtils.BuildSendAddLookAtConstraintCommand(gobject, target); AddCommand(command); }
public void SendEmpty(Transform transform) { NetCommand command = MixerUtils.BuildEmptyCommand(root, transform); AddCommand(command); }
public void SendAssignMaterial(AssignMaterialInfo info) { NetCommand command = MixerUtils.BuildAssignMaterialCommand(info); AddCommand(command); }
public void RestoreFromTrash(RestoreFromTrashInfo restoreFromTrash) { NetCommand command = MixerUtils.BuildRestoreFromTrashCommand(root, restoreFromTrash); AddCommand(command); }
public void SendRename(RenameInfo rename) { NetCommand command = MixerUtils.BuildRenameCommand(root, rename); AddCommand(command); }
public void SendTransform(Transform transform) { NetCommand command = MixerUtils.BuildTransformCommand(transform); AddCommand(command); }
public void SendMesh(MeshInfos meshInfos) { NetCommand command = MixerUtils.BuildMeshCommand(root, meshInfos); AddCommand(command); }
public void SendClearAnimations(ClearAnimationInfo info) { NetCommand command = MixerUtils.BuildSendClearAnimations(info); AddCommand(command); }
public void SendObjectVisibility(Transform transform) { NetCommand command = MixerUtils.BuildObjectVisibilityCommand(transform); AddCommand(command); }
public void SendBlenderBank(BlenderBankInfo info) { NetCommand command = MixerUtils.BuildSendBlenderBank(info); AddCommand(command); }
public void SendMoveKeyframe(MoveKeyInfo data) { NetCommand command = MixerUtils.BuildSendMoveKey(data); AddCommand(command); }
public void SendFrameStartEnd(FrameStartEnd range) { NetCommand command = MixerUtils.BuildSendFrameStartEndCommand(range.start, range.end); AddCommand(command); }
public void SendDelete(DeleteInfo deleteInfo) { NetCommand command = MixerUtils.BuildDeleteCommand(root, deleteInfo); AddCommand(command); }
public void SendAnimationCurve(CurveInfo data) { NetCommand command = MixerUtils.BuildSendAnimationCurve(data); AddCommand(command); }
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(); }