Ejemplo n.º 1
0
    void ReplyMailSendAgain(string[] args)
    {
        if (state == TimeLinePlayerSi.SendAgainWaitReply)
        {
            bool ok = int.Parse(args [0]) == 1;

            if (ok)
            {
                gameController.SendAgainGotReply();
                state = TimeLinePlayerSi.SendAgainGotReply;
            }
            else
            {
                // Should be implemented otherwise.
                gameController.SendAgainGotReply();
                state = TimeLinePlayerSi.SendAgainGotReply;
            }

            gameController.SendAgainGotReply();
            state = TimeLinePlayerSi.SendAgainGotReply;
        }

        else
        {
            Debug.Log("ClientSi: Time problem or state problem. Maybe I already received a response.");
        }
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        state    = TimeLinePlayerSi.WaitingUserFillIn;
        occupied = false;
        request  = new Dictionary <string, string> ();

        url = gameController.GetUrl();
        timeBeforeRetryingDemand = gameController.GetTimeBeforeRetryingDemand();
    }
Ejemplo n.º 3
0
    void ManageState()
    {
        switch (state)
        {
        case TimeLinePlayerSi.WaitingUserFillIn:
            break;

        case TimeLinePlayerSi.SendForm:

            request.Clear();
            request [KeySi.demand] = DemandSi.register;
            foreach (KeyValuePair <string, string> entry in userData)
            {
                request [entry.Key] = entry.Value;
            }

            StartCoroutine(AskServer(request));

            state = TimeLinePlayerSi.SendFormWaitReply;
            break;

        case TimeLinePlayerSi.SendAgain:

            request.Clear();
            request [KeySi.demand] = DemandSi.sendPasswordAgain;
            foreach (KeyValuePair <string, string> entry in userData)
            {
                request [entry.Key] = entry.Value;
            }

            StartCoroutine(AskServer(request));

            state = TimeLinePlayerSi.SendAgainWaitReply;
            break;

        case TimeLinePlayerSi.SendFormWaitReply:
        case TimeLinePlayerSi.SendAgainWaitReply:
            if (HasResponse())
            {
                HandleServerResponse();
            }

            break;

        case TimeLinePlayerSi.SendingAborted:
            break;

        case TimeLinePlayerSi.FormSent:
            break;
        }
    }
Ejemplo n.º 4
0
    // --------------------- For treating response ------------------------------------------------------- //

    void ReplyRegister(string[] args)
    {
        if (state == TimeLinePlayerSi.SendFormWaitReply)
        {
            int ok = int.Parse(args [0]);

            if (ok == 1)
            {
                gameController.FormSent();
                state = TimeLinePlayerSi.FormSent;
            }
            else
            {
                string reason = args [1];
                if (reason == ErrorSi.sendingAborted)
                {
                    gameController.SendingFailed();
                    state = TimeLinePlayerSi.SendingAborted;
                }
                else if (reason == ErrorSi.alreadyExists)
                {
                    gameController.AlreadyExists();
                    state = TimeLinePlayerSi.AlreadyExists;
                }
                else
                {
                    throw new System.Exception("Reason of failure not understood ('" + reason + "').");
                }
            }
        }

        else
        {
            Debug.Log("ClientSi: Time problem or state problem. Maybe I already received a response.");
        }
    }
Ejemplo n.º 5
0
 public void SendAgain()
 {
     state = TimeLinePlayerSi.SendAgain;
 }
Ejemplo n.º 6
0
    // ---------------------- For communicating with game controller ------------------------------ //

    public void SendForm(Dictionary <string, string> userData)
    {
        this.userData = userData;
        state         = TimeLinePlayerSi.SendForm;
    }