Пример #1
0
 /// <summary>
 ///     Message deserialization an initiation of handling methods.
 /// </summary>
 /// <param name="serializedData">Message string containing data.</param>
 private void GetData(string serializedData)
 {
     // don't need to handle empty messages
     if (string.IsNullOrEmpty(serializedData))
     {
         return;
     }
     try
     {
         // convert package string into stub
         NetworkPackageStub stub = JsonConvert.DeserializeObject <NetworkPackageStub>(serializedData);
         // check if calltype belongs to a known message type
         Type type;
         if (!m_PackageTypes.TryGetValue(stub.call, out type))
         {
             AciLog.LogFormat(LogType.Error, GetType().ToString(), "Can't handle NetworkPackage with calltype \"{0}\".", stub.call);
             return;
         }
         // deserialize into package instance
         INetworkPackage package = JsonConvert.DeserializeObject(serializedData, type) as INetworkPackage;
         // call handler mathods
         UnityMainThreadDispatcher.Instance().Enqueue(() => m_PackageRegistry.Handle(package));
     }
     catch (Exception e)
     {
         AciLog.LogException(e);
     }
 }
Пример #2
0
        // Initialization function to restore values from serialized object
        private void Intialize()
        {
            foreach (LocalizationData data in baseLocalization)
            {
                AddLocalizationData(data);
            }
            foreach (LocalizationData data in loadedData)
            {
                if (data.languageIETF == _currentLocalization)
                {
                    currentLocalizationData = data;
                    if (eventBroker != null)
                    {
                        eventBroker.Invoke(new LocalizationChangedArgs()
                        {
                            ietf            = _currentLocalization,
                            localeDecorator = currentLocalizationData.languageDescriptor
                        });
                    }
                }
            }

            if (currentLocalizationData == null)
            {
                AciLog.LogFormat(LogType.Error, "LocalizationManager", "Target language \"{0}\" could not be loaded from persivously serialzed values. Please check if the correct files are set on the LocalizationManager instance.", _currentLocalization);
                _currentLocalization = null;
            }

            initialized = true;
        }
Пример #3
0
        /// <summary>
        ///     Sends a <see cref="NetworkPackage" /> to all specified receivers.
        /// </summary>
        /// <param name="pkg">
        ///     <see cref="NetworkPackage" /> to send.
        /// </param>
        public void Send(INetworkPackage pkg)
        {
            if (_client == null)
            {
                // Do NOT call AciLog here to prevent looped method call
                Debug.unityLogger.LogWarning(GetType().Name, "Not properly initialized. Please call the Initialize() method before sending data.");
                return;
            }

            string json = JsonConvert.SerializeObject(pkg);

            // Do NOT call AciLog here to prevent looped method call
            Debug.unityLogger.Log(GetType().Name, "Sending package \"" + json + "\"");
            try
            {
                // Convert to binary
                byte[] data = Encoding.UTF8.GetBytes(json);
                for (int i = 0; i < _remoteEndPoints.Length; ++i)
                {
                    // Send msg to receiver
                    _client.Send(data, data.Length, _remoteEndPoints[i]);
                }
            }
            catch (Exception err)
            {
                AciLog.LogError(GetType().Name, err);
            }
        }
        private void EvaluateVisibility(SerializedProperty property)
        {
            string path = property.propertyPath.Contains(".")
                ? System.IO.Path.ChangeExtension(property.propertyPath, m_Attr.conditionName)
                : m_Attr.conditionName;

            m_Property = property.serializedObject.FindProperty(path);
            switch (m_Property.type)
            {
            case "bool":
                m_Hidden = m_Property.boolValue.Equals(m_Attr.conditionValue);
                return;

            case "int":
                m_Hidden = m_Property.intValue.Equals(m_Attr.conditionValue);
                return;

            case "long":
                m_Hidden = m_Property.longValue.Equals(m_Attr.conditionValue);
                return;

            case "float":
                m_Hidden = m_Property.floatValue.Equals(m_Attr.conditionValue);
                return;

            case "double":
                m_Hidden = m_Property.doubleValue.Equals(m_Attr.conditionValue);
                return;

            case "Enum":
                m_Hidden = m_Property.enumValueIndex.Equals((int)m_Attr.conditionValue);
                return;

            case "string":
                m_Hidden = m_Property.stringValue.Equals(m_Attr.conditionValue);
                return;

            case "Vector2":
                m_Hidden = m_Property.vector2Value.Equals(m_Attr.conditionValue);
                return;

            case "Vector3":
                m_Hidden = m_Property.vector3Value.Equals(m_Attr.conditionValue);
                return;

            default:
                AciLog.LogError("HidePropertyIfDrawer",
                                $"Trying to compare a property {m_Property.name} of type {m_Property.type} failed.");
                m_Hidden = false;
                return;
            }
        }
 private void LogStepTimings()
 {
     m_StringBuilder.Append("Step Timings,");
     for (int i = 0; i < m_TimeTrackingRepo.currentTime.durationsPerStep.Length; ++i)
     {
         m_StringBuilder.Append("Step ").Append(i).Append(",").Append(m_TimeTrackingRepo
                                                                      .currentTime.durationsPerStep[i]
                                                                      .ToString(new System.Globalization.CultureInfo("en-US"))).Append(",");
     }
     m_StringBuilder.Remove(m_StringBuilder.Length - 1, 1);
     AciLog.Log("WorkflowManager", m_StringBuilder.ToString());
     m_StringBuilder.Clear();
 }
Пример #6
0
        public async void SwitchScene(string sceneToUnload, string sceneToLoad)
        {
            if (sceneToUnload != null && IsSceneLoaded(sceneToUnload))
            {
                AciLog.Log("SceneService", $"Unloading scene {sceneToUnload}...");
                await SceneManager.UnloadSceneAsync(sceneToUnload, UnloadSceneOptions.UnloadAllEmbeddedSceneObjects);
            }

            if (sceneToLoad != null && !IsSceneLoaded(sceneToLoad))
            {
                AciLog.Log("SceneService", $"Loading scene {sceneToLoad}...");
                await SceneManager.LoadSceneAsync(sceneToLoad, LoadSceneMode.Additive);
            }
        }
Пример #7
0
        /// <summary>
        ///     Async network listener loop.
        /// </summary>
        /// <param name="token"><see cref="CancellationToken"/> that is used to interrupt listening process.</param>
        /// <returns></returns>
        private async Task ReceiveData(CancellationToken token)
        {
            using (UdpClient client = new UdpClient(port))
            {
                AciLog.LogFormat(LogType.Log, GetType().ToString(), "Starting to receive data on port {0}.", port);
                while (!token.IsCancellationRequested)
                {
                    UdpReceiveResult result = await client.ReceiveAsync();

                    string data = Encoding.UTF8.GetString(result.Buffer);
                    GetData(data);
                }
                AciLog.Log(GetType().ToString(), "Stopped listening for new data.");
            }
            m_Running = false;
        }
Пример #8
0
        /// <summary>
        ///     Initializes the network connection for sending data
        /// </summary>
        private void Initialize()
        {
            if (ips.Length != ports.Length)
            {
                AciLog.LogError(GetType().Name,
                                "IP/Port mismatch. Please check the configuration of the NetworkPublisher.");
            }

            _remoteEndPoints = new IPEndPoint[ips.Length];
            for (int i = 0; i < ips.Length; ++i)
            {
                _remoteEndPoints[i] = new IPEndPoint(IPAddress.Parse(ips[i]), ports[i]);
                AciLog.Log(GetType().Name, "Sending packages to " + ips[i] + " : " + ports[i]);
            }

            _client = new UdpClient();
        }
Пример #9
0
 private void LoadScene()
 {
     foreach (string sceneToLoad in scenesToLoad)
     {
         bool sceneLoaded = false;
         for (int i = 0; i < SceneManager.sceneCount; ++i)
         {
             if (SceneManager.GetSceneAt(i).name == sceneToLoad)
             {
                 sceneLoaded = true;
                 break;
             }
         }
         if (sceneLoaded)
         {
             continue;
         }
         AciLog.Log("Bootstrapper", $"Loading scene {sceneToLoad}...");
         SceneManager.LoadScene(sceneToLoad, LoadSceneMode.Additive);
     }
 }
        /// <inheritdoc />
        public void StartWork()
        {
            // don't bother if started or no workflow loaded
            if (m_IsRunning || m_CurrentWorkflowData == WorkflowData.Empty)
            {
                return;
            }

            m_FinalizerTokenSource = new CancellationTokenSource();
            m_TimeProvider.paused  = false;
            m_IsRunning            = true;
            m_EventBroker?.Invoke(new WorkflowStartArgs());
            m_EventBroker?.Invoke(new WorkflowStepFinalizedArgs()
            {
                lastStep     = -1,
                lastDataStep = -1,
                newStep      = m_CurrentStep,
                newDataStep  = m_CurrentDataStep
            });
            m_StepTriggerFactory.Create(m_CurrentWorkflowData.steps[currentDataStep]);
            AciLog.Log("WorkflowManager", "Started Workflow");
        }
        private void Start()
        {
            AciLog.Log(nameof(UIBootstrapper), $"Starting UI in {mode} mode.");

            NavigationParameters navigationParameters = new NavigationParameters();

            switch (mode)
            {
            case "nochat":
                throw new NotSupportedException("No Chat is no longer supported!");

            case "guest":
                navigationParameters.Add("isGuest", true);
                m_NavigationService.PushAsync("Idle", navigationParameters, AnimationOptions.Synchronous, false);
                break;

            case "kiosk":
            default:
                navigationParameters.Add("isGuest", false);
                m_NavigationService.PushAsync("Idle", navigationParameters, AnimationOptions.Synchronous, false);
                break;
            }
        }
        public void ReassignDisplays()
        {
            //if display are not dirty or there are not enough displays or cameras
            if (DontUseMultiDisplay || !dirty || Display.displays.Length == 1 || Camera.allCamerasCount == 1)
            {
                return;
            }

            //set displays to display and activate
            Camera.main.targetDisplay = UIDisplay;
            foreach (Camera cam in Camera.allCameras)
            {
                if (Camera.main == cam)
                {
                    continue;
                }
                cam.targetDisplay = ProjectionDisplay;
                break;
            }

            Display.displays[uiDisplay].Activate();
            Display.displays[ProjectionDisplay].Activate();
            AciLog.Log("DisplayManager", $"Displaying UI on display {UIDisplay} and Projection on display {ProjectionDisplay}.");
        }
Пример #13
0
 public void SendLog()
 {
     AciLog.Log("LogTester", "This is a test message.");
 }
Пример #14
0
 public void SendException()
 {
     AciLog.LogException(new Exception("This is a test exception."));
 }
Пример #15
0
 public void SendError()
 {
     AciLog.LogError("LogTester", "This is a test error.");
 }
Пример #16
0
 public void SendWarning()
 {
     AciLog.LogWarning("LogTester", "This is a test warning.");
 }
        /// <inheritdoc />
        public async void SetStep(int step)
        {
            // don't set step if finalizing
            if (m_Finalizing)
            {
                return;
            }

            // buffer the previous step numbers
            int m_LastStep     = m_CurrentStep;
            int m_LastDataStep = m_CurrentDataStep;

            // pause the time until we are done switching steps
            bool pauseState = m_TimeProvider.paused;

            m_TimeProvider.paused = true;

            // now advance/move back to the new step
            Action functor = null;
            int    diff    = 0;


            if (step > m_LastStep)
            {
                functor = AdvanceStep;
                diff    = step - m_LastStep;
            }
            else if (step < m_LastStep)
            {
                functor = RetreatStep;
                diff    = m_LastStep - step;
            }
            else
            {
                //restore state before attempt
                m_TimeProvider.paused = pauseState;
                return;
            }

            for (int i = 0; i < diff; ++i)
            {
                functor.Invoke();
            }

            // record time for previous step
            float stepTime = (float)m_TimeProvider.elapsed.TotalSeconds;

            m_TimeTrackingRepo.currentTime.durationsPerStep[m_LastStep] = stepTime;

            m_Finalizing = true;

            // invoke step event
            m_EventBroker?.Invoke(new WorkflowStepEndedArgs()
            {
                lastStep              = m_LastStep
                , lastDataStep        = m_LastDataStep
                , newStep             = m_CurrentStep
                , newDataStep         = m_CurrentDataStep
                , executedRepetitions = m_CurrentRepetition
            });

            try
            {
                await WaitForFinalizers(m_FinalizerTokenSource.Token);
            }
            catch (TaskCanceledException)
            {
                // Cancellation means we ended the workflow(quit), don't finalize
                m_Finalizing = false;
                return;
            }

            m_Finalizing = false;

            // stop workflow if we reached the end
            if (m_CurrentStep >= currentWorkflowData.numTotalSteps)
            {
                if (m_LastDataStep != -1)
                {
                    m_DisposalService.Dispose(m_CurrentWorkflowData.steps[m_LastDataStep].id);
                }
                StopWork();
                return;
            }

            // restore time for current step
            m_TimeProvider.Reset(false);
            float currentTime = m_TimeTrackingRepo.currentTime.durationsPerStep[m_CurrentStep];

            m_TimeProvider.paused = false;
            m_TimeProvider.Add(TimeSpan.FromSeconds(currentTime));

            LogStepTimings();
            AciLog.Log("WorkflowManager", $"Workflow Step, {m_CurrentStep}");
            AciLog.Log("WorkflowManager", $"Data Step: {m_CurrentDataStep}");

            if (m_LastDataStep != -1)
            {
                m_DisposalService.Dispose(m_CurrentWorkflowData.steps[m_LastDataStep].id);
            }

            m_StepTriggerFactory.Create(m_CurrentWorkflowData.steps[currentDataStep]);

            // invoke step event
            m_EventBroker?.Invoke(new WorkflowStepFinalizedArgs()
            {
                lastStep              = m_LastStep
                , lastDataStep        = m_LastDataStep
                , newStep             = m_CurrentStep
                , newDataStep         = m_CurrentDataStep
                , executedRepetitions = m_CurrentRepetition
            });
        }
Пример #18
0
 public override void Handle(EmotionPackage package)
 {
     AciLog.Log("MessageHandler", "I handled a message!");
 }