public IEnumerator Connect() { #endif #if !UNITY_EDITOR m_Socket = new Windows.Networking.Sockets.MessageWebSocket(); // In this example, we send/receive a string, so we need to set the MessageType to Utf8. m_Socket.Control.MessageType = Windows.Networking.Sockets.SocketMessageType.Utf8; m_Socket.MessageReceived += WebSocket_MessageReceived; m_Socket.Closed += WebSocket_Closed; try { Task connectTask = m_Socket.ConnectAsync(new Uri(mUrl.ToString())).AsTask(); // connectTask.ContinueWith(_ => this.SendMessageUsingMessageWebSocketAsync("Hello, World!")); } catch (Exception ex) { Windows.Web.WebErrorStatus webErrorStatus = Windows.Networking.Sockets.WebSocketError.GetStatus(ex.GetBaseException().HResult); // Add additional code here to handle exceptions. FlowNetworkManager.log(ex.Message); } yield return 0; }
public static void processCommand(FlowEvent incoming) { // runs the receive delegate that corresponds to the incoming command and stores any debug logs in debug_updates string debug_updates = receiveEvents[incoming.command](); // logs debug updates FlowNetworkManager.log(debug_updates); }
public void ApplySettingsForOpaqueDisplay() { FlowNetworkManager.log("Display is Opaque"); CameraCache.Main.clearFlags = CameraClearFlags_OpaqueDisplay; CameraCache.Main.nearClipPlane = NearClipPlane_OpaqueDisplay; CameraCache.Main.backgroundColor = BackgroundColor_OpaqueDisplay; SetQuality(OpaqueQualityLevel); }
public void ApplySettingsForTransparentDisplay() { FlowNetworkManager.log("Display is Transparent"); CameraCache.Main.clearFlags = CameraClearFlags_TransparentDisplay; CameraCache.Main.backgroundColor = BackgroundColor_TransparentDisplay; CameraCache.Main.nearClipPlane = NearClipPlane_TransparentDisplay; SetQuality(HoloLensQualityLevel); }
public static string Receive() { ProjectFetchEvent log = new ProjectFetchEvent(); JsonUtility.FromJsonOverwrite(FlowNetworkManager.reply, log); Config.objs = log.objs; foreach (FlowTObject obj in Config.objs) { FlowNetworkManager.log("creating object: " + obj.name); GameObject newObj = GameObject.CreatePrimitive(PrimitiveType.Cube); Mesh objMesh = newObj.GetComponent <MeshFilter>().mesh; objMesh.vertices = obj.vertices; objMesh.uv = obj.uv; objMesh.triangles = obj.triangles; objMesh.RecalculateBounds(); objMesh.RecalculateNormals(); newObj.transform.localPosition = new Vector3(obj.x, obj.y, obj.z); newObj.transform.localRotation = Quaternion.Euler(new Vector4(obj.q_x, obj.q_y, obj.q_z, obj.q_w)); newObj.transform.localScale = new Vector3(obj.s_x, obj.s_y, obj.s_z); MonoBehaviour.Destroy(newObj.GetComponent <Collider>()); newObj.AddComponent <BoxCollider>(); newObj.name = obj.name; newObj.AddComponent(typeof(FlowObject)); switch (Config.DEVICE_TYPE) { case FlowClient.CLIENT_HOLOLENS: newObj.AddComponent(typeof(TwoHandManipulatable)); newObj.AddComponent(typeof(BoundingBoxRig)); BoundingBox interactBox = (BoundingBox)Resources.Load("Prefabs/BoundingBoxBasic", typeof(BoundingBox)); newObj.GetComponent <TwoHandManipulatable>().BoundingBoxPrefab = interactBox; newObj.GetComponent <BoundingBoxRig>().BoundingBoxPrefab = interactBox; AppBar menuBar = (AppBar)Resources.Load("Prefabs/AppBar", typeof(AppBar)); newObj.GetComponent <BoundingBoxRig>().AppBarPrefab = menuBar; break; } newObj.GetComponent <FlowObject>().selected = true; Material mat = newObj.GetComponent <MeshRenderer>().material; mat.color = obj.color; newObj.GetComponent <FlowObject>().ft = new FlowTObject(newObj); newObj.GetComponent <FlowObject>().ft._id = obj._id; newObj.GetComponent <FlowObject>().ft.id = obj.id; newObj.GetComponent <FlowObject>().pastState = new FlowTObject(); newObj.GetComponent <FlowObject>().pastState.Copy(newObj.GetComponent <FlowObject>().ft); newObj.GetComponent <FlowObject>().ft.flowObject = newObj.GetComponent <FlowObject>(); } return("Receiving project open update: " + FlowNetworkManager.reply); }
private async Task SendMessageUsingMessageWebSocketAsync(string message) { using (var dataWriter = new Windows.Storage.Streams.DataWriter(m_Socket.OutputStream)) { dataWriter.WriteString(message); await dataWriter.StoreAsync(); dataWriter.DetachStream(); } FlowNetworkManager.log("Sending message using MessageWebSocket: " + message); }
public virtual void Send(WebSocket w, FlowEvent evt) { timestamp = DateTime.UtcNow.Ticks; string stringCmd = JsonUtility.ToJson(evt); FlowNetworkManager.log("Sending " + stringCmd); try { w.SendString(stringCmd); } catch { FlowNetworkManager.log("The update didnt send, and the websocket connection status is: " + w.connected + "\nthe json is: " + stringCmd); } }
private void WebSocket_Closed(Windows.Networking.Sockets.IWebSocket sender, Windows.Networking.Sockets.WebSocketClosedEventArgs args) { m_Error = "Closed"; FlowNetworkManager.log("WebSocket_Closed; Code: " + args.Code + ", Reason: \"" + args.Reason + "\""); // Add additional code here to handle the WebSocket being closed. }
public void Close() { FlowNetworkManager.log("Closing connection"); SocketClose(m_NativeRef); }