Esempio n. 1
0
    public IEnumerator UpdateGiftInfo(MyDelegateNS.NextFunc nextF = null)
    {
        string  hash       = Md5Sum(secretKey).ToLower();
        string  userNumber = ValueDeliverScript.UserID;
        float   tempTime   = 0;
        WWWForm form       = new WWWForm();

        form.AddField("Unique_number", userNumber);
        form.AddField("Gift_Time", ValueDeliverScript.myRewardTime);
        form.AddField("hash", hash);

        WWW www = new WWW(UpdateGiftInfoUrl, form);

        yield return(www);

        while (!www.isDone && www.error == null && tempTime < ServerConnectionTimeout)
        {
            tempTime += Time.deltaTime;
            yield return(0);
        }
        if (www.error != null || tempTime >= ServerConnectionTimeout)
        {
            //타임아웃처리
            Debug.Log("Disconnected!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            Debug.Log(www.error);
        }
        else
        {
            wwwResult = www.text;

            if (wwwResult == "GiftInfoUpdateSuccess")
            {
                Debug.Log(wwwResult);
                Debug.Log(www.error);
                //코루틴이 문제없이 끝났을 경우 실행하는 메소드.딜리게이트를 이용하여 실행함//
                if (nextF != null)
                {
                    nextF();
                }
            }
            else
            {
                Debug.Log("MailInfoUpdate Fail!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                Debug.Log(wwwResult);
                Debug.Log(www.error);
            }
        }
    }
Esempio n. 2
0
    public IEnumerator GetMailInfoBefoeSend2(string targetNumber, MyDelegateNS.NextFunc nextF = null)
    {
        Debug.Log("Tartget Number is      " + targetNumber);
        string hash     = Md5Sum(secretKey).ToLower();
        float  tempTime = 0;

        WWWForm form = new WWWForm();

        form.AddField("Unique_number", targetNumber);
        form.AddField("hash", hash);

        WWW www = new WWW(GetMailInfoFbid, form);

        yield return(www);

        while (!www.isDone && www.error == null && tempTime < ServerConnectionTimeout)
        {
            tempTime += Time.deltaTime;
            yield return(0);
        }
        if (www.error != null || tempTime >= ServerConnectionTimeout)
        {
            //타임아웃처리
            Debug.Log("Disconnected!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            //ServerPopUp.SetActive(true);
        }
        else
        {
            wwwResult = www.text;
            Debug.Log(wwwResult);
            var mailInfo = SimpleJSON.JSON.Parse(wwwResult);
            ValueDeliverScript.messageData = new MessageDataS[mailInfo["MailInfo"].Count];
            Debug.Log("Mail Info Count " + mailInfo["MailInfo"].Count);
            int count = 0;

            if (ValueDeliverScript.messageData.Length > 0)
            {
                while (count < mailInfo["MailInfo"].Count)
                {
                    ValueDeliverScript.messageData[count].To       = mailInfo["MailInfo"][count]["To"];
                    ValueDeliverScript.messageData[count].From     = mailInfo["MailInfo"][count]["From"];
                    ValueDeliverScript.messageData[count].Type     = mailInfo["MailInfo"][count]["Type"];
                    ValueDeliverScript.messageData[count].Ea       = mailInfo["MailInfo"][count]["Ea"];
                    ValueDeliverScript.messageData[count].Time     = mailInfo["MailInfo"][count]["Time"];
                    ValueDeliverScript.messageData[count].Contents = mailInfo["MailInfo"][count]["Contents"];

                    Debug.Log("MailInfo " + count + " To ===> " + ValueDeliverScript.messageData[count].To);
                    Debug.Log("MailInfo " + count + " From ===> " + ValueDeliverScript.messageData[count].From);
                    Debug.Log("MailInfo " + count + " Type ===> " + ValueDeliverScript.messageData[count].Type);
                    Debug.Log("MailInfo " + count + " Ea ===> " + ValueDeliverScript.messageData[count].Ea);
                    Debug.Log("MailInfo " + count + " Time ===> " + ValueDeliverScript.messageData[count].Time);
                    Debug.Log("MailInfo " + count + " Contents ===> " + ValueDeliverScript.messageData[count].Contents);
                    count++;
                }
            }
            else
            {
                Debug.Log("Message is Null");
            }
            if (nextF != null)
            {
                nextF();
            }
        }
    }
Esempio n. 3
0
    public IEnumerator UpdateSendMailInfo(string targetNumber, MyDelegateNS.NextFunc nextF)
    {
        yield return(StartCoroutine(GetMailInfoBefoeSend2(targetNumber)));

        string hash = Md5Sum(secretKey).ToLower();
        //string targetNumber = ValueDeliverScript.UserID;
        float   tempTime = 0;
        WWWForm form     = new WWWForm();

        string[] mailData = new string[ValueDeliverScript.messageData.Length];
        string   sendMail = "";

        if (ValueDeliverScript.messageData.Length > 0)
        {
            for (int i = 0; i < ValueDeliverScript.messageData.Length; i++)
            {
                Dictionary <string, object> MailDic = new Dictionary <string, object>();
                if (ValueDeliverScript.messageData[i].To == null)
                {
                    ValueDeliverScript.messageData[i].To = "0";
                }
                if (ValueDeliverScript.messageData[i].From == null)
                {
                    ValueDeliverScript.messageData[i].From = "0";
                }
                if (ValueDeliverScript.messageData[i].Type == null)
                {
                    ValueDeliverScript.messageData[i].Type = "0";
                }
                if (ValueDeliverScript.messageData[i].Ea == null)
                {
                    ValueDeliverScript.messageData[i].Ea = "0";
                }
                if (ValueDeliverScript.messageData[i].Time == null)
                {
                    ValueDeliverScript.messageData[i].Time = "0";
                }
                if (ValueDeliverScript.messageData[i].Contents == null)
                {
                    ValueDeliverScript.messageData[i].Contents = "0";
                }
                MailDic.Add("To", ValueDeliverScript.messageData[i].To);
                MailDic.Add("From", ValueDeliverScript.messageData[i].From);
                MailDic.Add("Type", ValueDeliverScript.messageData[i].Type);
                MailDic.Add("Ea", ValueDeliverScript.messageData[i].Ea);
                MailDic.Add("Time", ValueDeliverScript.messageData[i].Time);
                MailDic.Add("Contents", ValueDeliverScript.messageData[i].Contents);
                mailData[i] = MiniJSON.Json.Serialize(MailDic);

                sendMail = sendMail + ',' + mailData[i];

                Debug.Log(mailData[i]);
                Debug.Log(sendMail);
            }
        }
        char[] myChar       = { ',', '@' };
        string trimsendMail = sendMail.TrimStart(myChar);
        string sendData;

        Dictionary <string, object> SendMailDic = new Dictionary <string, object>();

        SendMailDic.Add("To", targetNumber);
        SendMailDic.Add("From", ValueDeliverScript.myFBid);
        SendMailDic.Add("Type", "1");
        SendMailDic.Add("Ea", "1");
        SendMailDic.Add("Time", DateTime.UtcNow.ToBinary().ToString());
        SendMailDic.Add("Contents", "1");
        sendData = MiniJSON.Json.Serialize(SendMailDic);

        if (ValueDeliverScript.messageData.Length == 0)
        {
            sendMail = sendData;
        }
        else
        {
            sendMail = trimsendMail + ',' + sendData;
        }

        Debug.Log(sendMail);
        form.AddField("Unique_number", targetNumber);
        form.AddField("Send_Mail", sendMail);
        form.AddField("hash", hash);

        WWW www = new WWW(UpdateMailInfoUrl, form);

        yield return(www);

        while (!www.isDone && www.error == null && tempTime < ServerConnectionTimeout)
        {
            tempTime += Time.deltaTime;
            yield return(0);
        }
        if (www.error != null || tempTime >= ServerConnectionTimeout)
        {
            //타임아웃처리
            Debug.Log("Disconnected!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        }
        else
        {
            wwwResult = www.text;

            if (wwwResult == "MailInfoUpdateSuccess")
            {
                Debug.Log(wwwResult);
                Debug.Log(www.error);

                //코루틴이 다 끝나고 실행될 메소드//딜리게이트로 작성됨//
                nextF();
            }
            else
            {
                Debug.Log("MailInfoUpdate Fail!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                Debug.Log(wwwResult);
                Debug.Log(www.error);
            }
        }
    }