Example #1
0
    //  _////////////////////////////////////////////////_    _____   Send   _____   Receive   _____
    public void SendAndRciv()
    {
        //Ag.NetExcpt.WASActionTime = DateTime.Now;

        IsOK = null;
        Ag.LogString(" {{ " + TpStr + " }} :  SendAndRciv () >>> SEND ing >>    " + SendStr);
        try {
            RetryN++;

            RcvdStr = WAS.SendWASvrMessage(SendStr, Encript);
            Result  = new WasResult();
            Ag.LogString(" {{ " + TpStr + " }}    Received  () :: " + RcvdStr);
            if (RcvdStr == "CATCH")
            {
                IsOK          = false;
                Result.result = -99;
                return;
            }

            IsOK  = true;
            NdObj = JSON.Parse(RcvdStr);

            Result.result = -1;                                   // Default
            try {
                Result.serviceCode = NdObj ["serviceCode"].AsInt; // JData ["serviceCode"];
                Result.result      = NdObj ["result"].AsInt;      // (int)JData ["result"];  //  OK => 0 ...

                if (Result.result == 501)
                {
                    Ag.NetExcpt.WasLoginDuplicate = true;
                }
                else
                {
                    Ag.NetExcpt.WasLoginDuplicate = false;
                }

                Ag.LogString(" {{ " + TpStr + " }}          Result : " + Result.result + "        serviceCode : " + Result.serviceCode);
            } catch {
                Ag.LogIntenseWord(" {{ " + TpStr + " }} SendAndRciv () >>>  No result, serviceCode  !!   ");
            }
            try {
                if ((Result.result == 0 || Result.result == 4) && NdObj ["cash1"].AsBool)
                {
                    User.mCash1 = Ag.mySelf.mCash1 = NdObj ["cash1"].AsInt;
                    User.mCash2 = Ag.mySelf.mCash2 = NdObj ["cash2"].AsInt;
                    User.mGold  = Ag.mySelf.mGold = NdObj ["gold"].AsInt;
                    User.ShowCurrentCash();   // Log ..
                }
            } catch {
                Ag.LogString(" {{ " + TpStr + " }}  Result : " + Result.result + " serviceCode : " + Result.serviceCode + "   has  No Cash Info ...  OK ");
                //" No Cash Info ...  OK  ".HtLog ();
            }

            try {
                Ag.TimeNow       = long.Parse(NdObj ["serverTimeStampToUTC"]) / 1000;
                Ag.DTNowTickMark = DateTime.Now;
                Ag.LogString("   ServerTime :: " + Ag.UnixTimeStampToDateTime(Ag.TimeNow));
                //Ag.LogString ("   Parsing Time :: >>>    " + Ag.TimeNow);
            } catch {
                Ag.LogDouble(" {{ " + TpStr + " }}   ::   has  No Time Info ...  OK ");
            }

            if (postAction != null)
            {
                postAction();
            }
            //Ag.LogString (" {{ " + TpStr + " }} SendAndRciv () :: " + RcvdStr);
            Ag.LogNewLine(3);
        } catch {
            Ag.LogNewLine(5);
            Ag.LogString(" {{ " + TpStr + " }} SendAndRciv () >>>   Catch  !!!!!!!!   ");
            Ag.LogNewLine(5);
            CatchAction();
        }
    }