예제 #1
0
        public static void StopMission()
        {
            if (!GcsSocket.Alive)
            {
                Debug.Log("Error: Socket connection could not be established.");
                SceneFlowController.LoadErrorScene();
            }

            GcsSocket.Emit(STOP_MISSION,
                           ParticipantBehavior.Participant.CurrentMission);
        }
예제 #2
0
        public static void StartMission()
        {
            if (!GcsSocket.Alive)
            {
                Debug.Log("Error: Socket connection could not be established.");
                SceneFlowController.LoadErrorScene();
            }

            GcsSocket.Emit(START_MISSION,
                           ParticipantBehavior.Participant.CurrentMission);
            Started = true;
            Lifecycle.EventManager.OnStarted();
        }
        /// <summary>
        /// Attempts to create a participant by sending an HTTP request to server and waiting for the response.
        /// </summary>
        /// <param name="data">
        /// The metadata of the participant such as their group number and proctor name.
        /// </param>
        /// <returns></returns>
        private IEnumerator NewParticipantRequest(ParticipantData data)
        {
            var form = new WWWForm();

            form.AddField("adaptive", data.Adaptive ? "1" : "0");
            form.AddField("transparent", data.Transparent ? "1" : "0");
            form.AddField("group_number", data.Group);
            form.AddField("proctor_name", data.ProctorName);

            var www = UnityWebRequest.Post(ServerURL.INSERT_PARTICIPANT, form);

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
                SceneFlowController.LoadErrorScene();
            }
            else
            {
                var result = JSON.Parse(www.downloadHandler.text);
                Debug.Log(result);
                if (result["failed"].AsBool)
                {
                    SceneFlowController.LoadErrorScene();
                }
                else
                {
                    data.Id = result["data"].AsInt;
                }


                Participant = new Participant
                {
                    Data           = data,
                    CurrentMission = 1,
                    CurrentSurvey  = 1
                };

                Debug.Log(string.Format(
                              "New Participant Made: Transparency={0} Adaptive={1} Proctor={2}, ID={3}",
                              Participant.Data.Transparent, Participant.Data.Adaptive,
                              Participant.Data.ProctorName,
                              Participant.Data.Id));
                EventManager.OnNewParticipantMade(new NewParticipantEventArgs
                {
                    Data = data
                });
            }
        }
예제 #4
0
        /// <summary>
        /// Starts the initialization process for a mission.
        /// </summary>
        public static void InitializeMission()
        {
            if (!GcsSocket.Alive)
            {
                Debug.Log("Error: Socket connection could not be established.");
                SceneFlowController.LoadErrorScene();
            }
            ;

            var initializeMissionParameters = string.Format("mission{0}-{1}-{2}-{3}",
                                                            ParticipantBehavior.Participant.CurrentMission,
                                                            ParticipantBehavior.Participant.Data.Adaptive ? "true" : "false",
                                                            ParticipantBehavior.Participant.Data.Id,
                                                            ParticipantBehavior.Participant.Data.Transparent ? "true" : "false");

            Debug.Log("Initializing Mission.  Parameters: " + initializeMissionParameters);

            GcsSocket.Emit(INITIALIZE_MISSION, initializeMissionParameters);

            Lifecycle.EventManager.OnInitialize(ParticipantBehavior.Participant.CurrentMission);
        }