Exemplo n.º 1
0
        private void OnHeadsetCalibrationUpdated(HeadsetCalibrationData data)
        {
            if (holographicCameraBroadcaster != null)
            {
                using (MemoryStream memoryStream = new MemoryStream())
                    using (BinaryWriter writer = new BinaryWriter(memoryStream))
                    {
                        writer.Write(HeadsetCalibration.CalibrationDataReceivedCommandHeader);
                        data.SerializeAndWrite(writer);
                        writer.Flush();

                        Debug.Log("Sending headset calibration data payload.");
                        connectionManager.Broadcast(memoryStream.ToArray());
                    }
            }
        }
Exemplo n.º 2
0
        private void SendDeviceInfo()
        {
            using (MemoryStream memoryStream = new MemoryStream())
                using (BinaryWriter message = new BinaryWriter(memoryStream))
                {
                    message.Write(DeviceInfoObserver.DeviceInfoCommand);
                    message.Write(GetMachineName());
                    message.Write(GetIPAddress());

                    connectionManager.Broadcast(memoryStream.ToArray());
                }
        }
        private void SendCameraPose(float timestamp, Vector3 cameraPosition, Quaternion cameraRotation)
        {
            using (MemoryStream stream = new MemoryStream())
                using (BinaryWriter message = new BinaryWriter(stream))
                {
                    message.Write(HolographicCameraObserver.CameraCommand);
                    message.Write(timestamp);
                    message.Write(cameraPosition);
                    message.Write(cameraRotation);

                    tcpConnectionManager.Broadcast(stream.ToArray());
                }
        }
 /// <inheritdoc />
 public bool SendData(byte[] data, NetworkPriority priority = NetworkPriority.Default)
 {
     if (net != null &&
         net.HasConnections)
     {
         net.Broadcast(data);
         return(true);
     }
     else
     {
         Debug.LogWarning("Payload not sent, no connection established");
         return(false);
     }
 }
 private async void SendCalibrationDataAsync()
 {
     using (MemoryStream memoryStream = new MemoryStream())
         using (BinaryWriter message = new BinaryWriter(memoryStream))
         {
             StorageFile file = (await KnownFolders.PicturesLibrary.TryGetItemAsync(@"CalibrationData.json").AsTask()) as StorageFile;
             if (file != null)
             {
                 byte[] contents = (await FileIO.ReadBufferAsync(file)).ToArray();
                 message.Write("CalibrationData");
                 message.Write(contents.Length);
                 message.Write(contents);
                 tcpConnectionManager.Broadcast(memoryStream.ToArray());
             }
         }
 }
Exemplo n.º 6
0
        private void Update()
        {
            if (!connectionManager.HasConnections)
            {
                return;
            }

            if (broadcastSent &&
                broadcastReceived)
            {
                Debug.Log("Broadcasts sent and received, attempting to disconnect");
                connectionManager.DisconnectAll();
                Debug.Log("TCPConnectionManager has disconnected");
            }
            else if ((Time.time - lastBroadcast) > timeBetweenBroadcasts)
            {
                var message = runAsServer ? "Message from server" : "Message from client";
                connectionManager.Broadcast(Encoding.ASCII.GetBytes(message));
                broadcastSent = true;

                lastBroadcast = Time.time;
            }
        }