/// <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); } } }
/// <summary> /// Updates the session filter with the provided <see cref="List{int}">Lists</see> of sessions and conditions. /// </summary> /// <param name="sessions">The indices of the sessions to select.</param> /// <param name="conditions">The indices of the conditions to select.</param> public void UpdateSessionFilter(List <int> sessions, List <int> conditions) { CurrentStudyConditions = conditions; CurrentStudySessions = sessions; UpdateTimestampBounds(); var message = new MessageUpdateSessionFilter(sessions, conditions); Services.NetworkManager().SendMessage(message.Pack()); SessionFilterEventBroadcast.Invoke(); }