public void EnqueueMessage(rdtTcpMessage message) { if (this.m_writeThread != null) { this.m_writeThread.EnqueueMessage(message); } }
private void OnReadMessage(rdtTcpMessage message) { if (message is rdtTcpMessageLog) { rdtTcpMessageLog log = (rdtTcpMessageLog)message; switch (log.m_logType) { case LogType.Error: Debug.LogError(log); break; case LogType.Assert: Debug.LogError(log); break; case LogType.Warning: Debug.LogWarning(log); break; case LogType.Log: Debug.Log(log); break; case LogType.Exception: Debug.LogError(log); break; } } if (this.m_messageCallbacks.ContainsKey(message.GetType())) { this.m_messageCallbacks[message.GetType()](message); } }
private void OnReadMessage(rdtTcpMessage message) { if (this.m_messageCallbacks.ContainsKey(message.GetType())) { this.m_messagesToProcess.Add(message); } }
private void OnUpdateComponentProperties(rdtTcpMessage message) { rdtDebug.Debug(this, "OnUpdateComponentProperties", new object[0]); rdtTcpMessageUpdateComponentProperties properties = (rdtTcpMessageUpdateComponentProperties)message; GameObject gob = this.FindGameObject(properties.m_gameObjectInstanceId); if (gob != null) { UnityEngine.Component owner = this.FindComponent(gob, properties.m_componentInstanceId); if (owner == null) { rdtDebug.Error(this, "Tried to update component with id {0} (name={1}) but couldn't find it!", new object[] { properties.m_componentInstanceId, properties.m_componentName }); } else { if (owner is Behaviour) { ((Behaviour)owner).enabled = properties.m_enabled; } else if (owner is Renderer) { ((Renderer)owner).enabled = properties.m_enabled; } else if (owner is Collider) { ((Collider)owner).enabled = properties.m_enabled; } if (properties.m_properties != null) { this.m_server.SerializerRegistry.WriteAllFields(owner, properties.m_properties); } } } }
private void OnMessageGameObjectComponents(rdtTcpMessage message) { this.m_components = new rdtTcpMessageComponents?((rdtTcpMessageComponents)message); List <rdtTcpMessageComponents.Component> components = this.m_components.Value.m_components; for (int i = 0; i < components.Count; i++) { rdtTcpMessageComponents.Component component = components[i]; if (component.m_properties == null) { rdtDebug.Debug(this, "Component '{0}' has no properties", new object[] { component.m_name }); } else { for (int j = 0; j < component.m_properties.Count; j++) { rdtTcpMessageComponents.Property property = component.m_properties[j]; property.Deserialise(this.m_serializerRegistry); component.m_properties[j] = property; } components[i] = component; } } base.Repaint(); }
private void OnUpdateGameObjectProperties(rdtTcpMessage message) { rdtTcpMessageUpdateGameObjectProperties properties = (rdtTcpMessageUpdateGameObjectProperties)message; GameObject obj2 = this.FindGameObject(properties.m_instanceId); if (obj2 != null) { obj2.SetActive(properties.m_enabled); obj2.layer = properties.m_layer; obj2.tag = properties.m_tag; } }
public void EnqueueMessage(rdtTcpMessage message) { lock (this.m_messageQueue) { using (MemoryStream stream = new MemoryStream()) { new BinaryFormatter().Serialize(stream, message); byte[] item = stream.ToArray(); this.m_messageQueue.Enqueue(item); } } this.m_event.Set(); }
private void OnConnected() { if (this.m_listener.Pending()) { this.m_listener.AcceptTcpClient().Close(); } if ((!this.m_client.Connected || !this.m_readThread.IsConnected) || !this.m_writeThread.IsConnected) { this.SetState(State.Disconnected); } else { this.m_dispatcher.Update(); bool flag = false; bool flag2 = false; for (int i = 0; i < this.m_messagesToProcess.Count; i++) { System.Type type = this.m_messagesToProcess[i].GetType(); if (type == typeof(rdtTcpMessageGetGameObjects)) { if (flag) { this.m_messagesToProcess.RemoveAt(i); i--; } else { flag = true; } } else if (type == typeof(rdtTcpMessageGetComponents)) { if (flag2) { this.m_messagesToProcess.RemoveAt(i); i--; } else { flag2 = true; } } } while (this.m_messagesToProcess.Count > 0) { rdtTcpMessage message2 = this.m_messagesToProcess[0]; this.m_messagesToProcess.RemoveAt(0); this.m_messageCallbacks[message2.GetType()](message2); } } }
private void OnMessageGameObjects(rdtTcpMessage message) { rdtTcpMessageGameObjects objects = (rdtTcpMessageGameObjects)message; this.m_gameObjects = objects.m_allGobs; this.m_tree.Clear(); this.BuildTree(); if (this.m_selected.HasValue) { this.m_tree.SetSelected(this.m_selected.Value, true, false, false); } else { this.m_tree.ClearSelected(true, false, false); } base.Repaint(); }
private void OnRequestGameObjects(rdtTcpMessage message) { rdtTcpMessageGameObjects objects = new rdtTcpMessageGameObjects(); #if UNITY_5 Scene activeScene = SceneManager.GetActiveScene(); if (activeScene.rootCount > this.m_gameObjects.Capacity) { this.m_gameObjects.Capacity = activeScene.rootCount; } this.m_gameObjects.Clear(); activeScene.GetRootGameObjects(this.m_gameObjects); #else m_gameObjects.Clear(); Transform[] allTrans = GameObject.FindObjectsOfType <Transform>(); for (int ii = 0; ii < allTrans.Length; ++ii) { Transform tran = allTrans[ii]; if (tran.parent != null) { continue; } m_gameObjects.Add(tran.gameObject); } #endif int count = this.m_gameObjects.Count; List <GameObject> gameObjects = this.m_gameObjects; if (count > this.m_allGobs.Capacity) { this.m_allGobs.Capacity = count; } this.m_allGobs.Clear(); for (int i = 0; i < count; i++) { GameObject g = gameObjects[i]; if ((g.hideFlags == HideFlags.None) && (g.transform.hideFlags == HideFlags.None)) { this.AddGameObject(g, this.m_allGobs); } } objects.m_allGobs = this.m_allGobs; this.m_server.EnqueueMessage(objects); this.m_gameObjects.Clear(); }
private void OnReading() { try { bool flag = true; int count = this.m_reader.ReadInt32(); byte[] buffer = this.m_reader.ReadBytes(count); flag = false; using (MemoryStream stream = new MemoryStream(buffer)) { Action action = null; BinaryFormatter formatter = new BinaryFormatter(); rdtTcpMessage message = formatter.Deserialize(stream) as rdtTcpMessage; if (message != null) { if (action == null) { action = delegate { this.m_callback(message); }; } this.m_dispatcher.Enqueue(action); } else { rdtDebug.Error(this, "Ignoring invalid message", new object[0]); } } if (flag) { this.m_state = State.LostConnection; } } catch (SocketException exception) { rdtDebug.Log(this, exception, rdtDebug.LogLevel.Debug, "{0} socket exception", new object[] { this.m_name }); rdtDebug.Debug(this, "{3} ErrorCode={0} SocketErrorCode={1} NativeErrorCode={2}", new object[] { exception.ErrorCode, exception.SocketErrorCode, exception.NativeErrorCode, this.m_name }); this.m_state = State.LostConnection; } catch (IOException exception2) { SocketException innerException = exception2.InnerException as SocketException; if (innerException != null) { rdtDebug.Log(this, innerException, rdtDebug.LogLevel.Debug, "{0} socket exception", new object[] { this.m_name }); rdtDebug.Debug(this, "{3} ErrorCode={0} SocketErrorCode={1} NativeErrorCode={2}", new object[] { innerException.ErrorCode, innerException.SocketErrorCode, innerException.NativeErrorCode, this.m_name }); } else { rdtDebug.Log(this, exception2, rdtDebug.LogLevel.Debug, "{0} thread lost connection", new object[] { this.m_name }); } this.m_state = State.LostConnection; } catch (ObjectDisposedException) { rdtDebug.Debug(this, "{0} thread object disposed, lost connection", new object[] { this.m_name }); this.m_state = State.LostConnection; } catch (Exception exception4) { rdtDebug.Error(this, exception4, "{0} thread unknown exception", new object[] { this.m_name }); } }
private void OnRequestGameObjectComponents(rdtTcpMessage message) { rdtTcpMessageGetComponents components = (rdtTcpMessageGetComponents)message; if (components.m_instanceId != 0) { GameObject obj2 = this.FindGameObject(components.m_instanceId); if (obj2 != null) { rdtTcpMessageComponents components2 = new rdtTcpMessageComponents(); components2.m_instanceId = components.m_instanceId; components2.m_components = new List <rdtTcpMessageComponents.Component>(); components2.m_layer = obj2.layer; components2.m_tag = obj2.tag; components2.m_enabled = obj2.activeSelf; this.m_components.Clear(); obj2.GetComponents <UnityEngine.Component>(this.m_unityComponents); if (this.m_unityComponents.Count > this.m_components.Capacity) { this.m_components.Capacity = this.m_unityComponents.Count; } for (int i = 0; i < this.m_unityComponents.Count; i++) { UnityEngine.Component owner = this.m_unityComponents[i]; if (owner == null) { rdtDebug.Debug(this, "Component is null, skipping", new object[0]); } else { List <rdtTcpMessageComponents.Property> list = this.m_server.SerializerRegistry.ReadAllFields(owner); if (list == null) { rdtDebug.Debug(this, "Properties are null, skipping", new object[0]); } else { rdtTcpMessageComponents.Component item = new rdtTcpMessageComponents.Component(); if (owner is Behaviour) { item.m_canBeDisabled = true; item.m_enabled = ((Behaviour)owner).enabled; } else if (owner is Renderer) { item.m_canBeDisabled = true; item.m_enabled = ((Renderer)owner).enabled; } else if (owner is Collider) { item.m_canBeDisabled = true; item.m_enabled = ((Collider)owner).enabled; } else { item.m_canBeDisabled = false; item.m_enabled = true; } System.Type type = owner.GetType(); item.m_name = type.Name; item.m_assemblyName = type.AssemblyQualifiedName; item.m_instanceId = owner.GetInstanceID(); item.m_properties = list; this.m_components.Add(item); } } } components2.m_components = this.m_components; this.m_unityComponents.Clear(); this.m_server.EnqueueMessage(components2); } } }