Ejemplo n.º 1
0
        /// <summary>
        /// Loads the study with the provided index.
        /// </summary>
        /// <param name="studyIndex">The index of the study to load.</param>
        public async void LoadStudy(int studyIndex)
        {
            _ = ProgressIndicator.StartProgressIndicator("Loading data...");

            // tell other clients to also load the study
            var command = new MessageLoadStudy(studyIndex);

            Services.NetworkManager().SendMessage(command.Pack());

            // delete all current Visualizations
            Services.VisManager().DeleteAllVisualizations(false);

            // load the actual data
            await Services.DataManager().LoadStudyAsync(studyIndex);

            StudyChangeBroadcast.Invoke(studyIndex);

            // set session filter (also remotely)
            Services.StudyManager().UpdateSessionFilter(new List <int> {
                0
            }, new List <int> {
                0
            });

            _ = ProgressIndicator.StopProgressIndicator();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles a new client. All relevant data is sent to the client to get it up to speed.
        /// </summary>
        /// <param name="client">The new client.</param>
        internal void HandleNewClient(Socket client)
        {
            if (!IsServer || Network == null)
            {
                return;
            }

            // Send world anchor data to client
            Services.AnchorManager().SendAnchor(client);

            if (Services.DataManager().CurrentStudyIndex != -1)
            {
                // assign id to client
                var clientMessage = new MessageAcceptClient(clientCounter++);
                Network.SendToClient(clientMessage.Pack(), client);

                // send client information about study
                var studyMessage = new MessageLoadStudy(Services.DataManager().CurrentStudyIndex);
                Network.SendToClient(studyMessage.Pack(), client);

                // send client information about session/condition filters
                var sessionFilterMessage = new MessageUpdateSessionFilter(Services.StudyManager().CurrentStudySessions, Services.StudyManager().CurrentStudyConditions);
                Network.SendToClient(sessionFilterMessage.Pack(), client);

                // send client information about time filter
                var timeFilterMessage = new MessageUpdateTimeFilter(Services.StudyManager().CurrentTimeFilter);
                Network.SendToClient(timeFilterMessage.Pack(), client);

                // send client information about timeline
                var timelineMessage = new MessageUpdateTimeline(new TimelineState(Services.StudyManager().TimelineStatus, Services.StudyManager().CurrentTimestamp, Services.StudyManager().MinTimestamp, Services.StudyManager().MaxTimestamp, Services.StudyManager().PlaybackSpeed));
                Network.SendToClient(timelineMessage.Pack(), client);

                // send client information about vis containers
                //foreach (var container in Services.VisManager().ViewContainers.Values)
                //{
                //    var visContainer = new VisContainer
                //    {
                //        Id = container.Id,
                //        Orientation = new float[] { container.transform.rotation.x, container.transform.rotation.y, container.transform.rotation.z, container.transform.rotation.w },
                //        Position = new float[] { container.transform.position.x, container.transform.position.y, container.transform.position.z },
                //        Scale = new float[] { container.transform.localScale.x, container.transform.localScale.y, container.transform.localScale.z }
                //    };
                //    var containerMessage = new MessageCreateVisContainer(visContainer);
                //    Network.SendToClient(containerMessage.Pack(), client);
                //}

                // send client information about visualizations
                foreach (var vis in Services.VisManager().Visualizations.Values)
                {
                    var visMessage = new MessageCreateVisualization(vis.Settings);
                    Network.SendToClient(visMessage.Pack(), client);
                }
            }
        }