//public ResendOtpResponse ResendOtp(ResendOtpRequest request)
        //{
        //    ResendOtpResponse response = new ResendOtpResponse();
        //    response.otp_details = new OtpDetailsDto();
        //    Consumer consumer = null;
        //    try
        //    {
        //        using (UserDao userDao = new UserDao())
        //        {
        //            consumer = GetAuthUser(userDao, request.user_id, request.auth_token);
        //        }
        //        if (consumer == null)
        //        {
        //            MakeNouserResponse(response);
        //            return response;
        //        }
        //        OTPServices.ResendOTP(request.user_id, consumer.PhoneNumber, "C");
        //        response.code = 0;
        //        response.has_resource = 1;
        //        response.message = MessagesSource.GetMessage("otp.resent");
        //        response.otp_details.send_otp = 1;
        //        return response;
        //    }
        //    catch (Exception ex)
        //    {
        //        response.MakeExceptionResponse(ex);
        //        return response;
        //    }
        //}

        public UserExistsResponse CheckUserExists(UserExistsRequest request)
        {
            request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number);
            UserExistsResponse response = new UserExistsResponse();
            Consumer           consumer = null;

            try
            {
                using (UserDao dao = new UserDao())
                {
                    consumer = dao.FindByMobileNumber(request.mobile_number);
                }
                if (consumer == null)
                {
                    MakeNouserResponse(response);
                    return(response);
                }
                UsersHelper.CopyFromEntity(response, consumer);
                response.code         = 0;
                response.has_resource = 1;
                response.message      = MessagesSource.GetMessage("user.found");
                return(response);
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
Example #2
0
        public async Task <bool> CheckUser(string name)
        {
            try
            {
                ActorId           id        = new ActorId(1);
                var               gateproxy = id.Proxy <IGate>();
                GateRequest       request   = new GateRequest();
                UserExistsRequest uer       = new Shared.Requests.UserExistsRequest();
                uer.UserName        = name;
                request.Kind        = 1;
                request.JsonPayload = uer.Serialize();
                GateResponse response = await gateproxy.Process(request);

                if (response.ResultCode == 200)
                {
                    UserExistsResponse r = response.JsonPayload.Deserialize <UserExistsResponse>();
                    return(r.Exists);
                }

                return(false);
            }
            catch (Exception e)
            {
                await Logger.LogMessage(e);

                throw (e);
            }
        }
Example #3
0
        public async Task <IResponse> Process(IRequest request)
        {
            try
            {
                UserExistsRequest  uer      = request as UserExistsRequest;
                UserExistsResponse response = new UserExistsResponse();

                if (!string.IsNullOrEmpty(uer.UserName))
                {
                    //Compute actor id for user name
                    ActorId userid    = uer.UserName.ToLowerInvariant().ToMD5GuidActorId();
                    var     userproxy = userid.Proxy <IUser>();
                    bool    exists    = await userproxy.isCreatedAsync(); //Note: change to NOT create actors later, possible vector

                    response.Exists = exists;
                    response.Status = System.Net.HttpStatusCode.OK;
                }
                else
                {
                    response.Exists = false;
                    response.Status = System.Net.HttpStatusCode.NotAcceptable;
                }
                return(response);
            }
            catch (Exception E)
            {
                E.Log();
                ErrorResponse errorresponse = new ErrorResponse(E.Message);
                return(errorresponse);
            }
        }
Example #4
0
 public static void CopyFromEntity(UserExistsResponse response, Consumer consumer)
 {
     if (response.user_status == null)
     {
         response.user_status = new UserStatusDto();
     }
     response.user_status.user_id     = consumer.ConsID;
     response.user_status.auth_token  = consumer.AccToken;
     response.user_status.user_exists = 1;
 }
Example #5
0
        public void ProcessResponse(ClientGateResponse response)
        {
            _recievedResonses++;
            if (response.ResultCode == (int)HttpStatusCode.OK)
            {
                switch ((RequestProcessorEnum)response.Kind)
                {
                case RequestProcessorEnum.Session:
                {
                    CreateSessionResponse csresp = response.JsonPayload.Deserialize <CreateSessionResponse>();
                    if (csresp.Status == HttpStatusCode.OK)
                    {
                        _SessionKey = csresp.SessionKey;
                        m_client.Invoke("Map", _UserId.ToString());
                    }
                }
                break;

                case RequestProcessorEnum.UserExists:
                {
                    UserExistsResponse r = response.JsonPayload.Deserialize <UserExistsResponse>();
                    if (!r.Exists)
                    {
                        //Create user
                        CreateUserRequest cr = new CreateUserRequest();
                        cr.UserName = _UserName;
                        cr.Password = _Password;
                        m_client.Invoke("Exec", cr.CreateRequest(RequestProcessorEnum.CreateUser, _UserId).Serialize());
                    }
                    else
                    {
                        LoginUserRequest lr = new LoginUserRequest();
                        lr.UserName = _UserName;
                        lr.Password = _Password;
                        m_client.Invoke("Exec", lr.CreateRequest(RequestProcessorEnum.LoginUser, _UserId).Serialize());
                    }
                }
                break;

                case RequestProcessorEnum.CreateUser:
                    CreateUserResponse cresp = response.JsonPayload.Deserialize <CreateUserResponse>();
                    if (cresp.Sucessful)
                    {
                        _UserId = cresp.UserId;
                        CreateSessionRequest csesr = new CreateSessionRequest();
                        csesr.UserId     = _UserId;
                        csesr.SessionKey = string.Empty;
                        m_client.Invoke("Exec", csesr.CreateRequest(RequestProcessorEnum.Session, _UserId).Serialize());
                    }
                    break;

                case RequestProcessorEnum.LoginUser:
                {
                    LoginUserResponse lur = response.JsonPayload.Deserialize <LoginUserResponse>();
                    if (lur.Status == HttpStatusCode.OK)
                    {
                        _UserId = lur.UserId;
                        CreateSessionRequest csesr = new CreateSessionRequest();
                        csesr.UserId     = _UserId;
                        csesr.SessionKey = string.Empty;
                        m_client.Invoke("Exec", csesr.CreateRequest(RequestProcessorEnum.Session, _UserId).Serialize());
                    }
                }
                break;

                case RequestProcessorEnum.TankPosition:
                {
                    TankPosistionResponse tr = response.JsonPayload.Deserialize <TankPosistionResponse>();
                    if (OnActionTrack != null)
                    {
                        OnActionTrack(tr.TankId, new Vector3(tr.x, tr.y, tr.z), tr.r);
                    }
                }
                break;

                case RequestProcessorEnum.FireShell:
                {
                    FireShellResponse fr = response.JsonPayload.Deserialize <FireShellResponse>();
                    if (OnActionFire != null)
                    {
                        OnActionFire(new Vector3(fr.pos.x, fr.pos.y, fr.pos.z),
                                     new Quaternion(fr.rot.x, fr.rot.y, fr.rot.z, fr.rot.w),
                                     new Vector3(fr.vel.x, fr.vel.y, fr.vel.z));
                    }
                }
                break;

                case RequestProcessorEnum._System_MapConnection:
                {
                    //Map
                    _isMapped = true;
                }
                break;

                case RequestProcessorEnum.TakeDamage:
                {
                    TakeDamageResponse tdr = response.JsonPayload.Deserialize <TakeDamageResponse>();
                    if (OnActionSetDamage != null)
                    {
                        OnActionSetDamage(tdr.TankId, tdr.Health);
                    }
                }
                break;

                case RequestProcessorEnum.JoinOrCreateGame:
                {
                    //Join or create game session
                    JoinOrCreateGameSessionResponse jcr = response.JsonPayload.Deserialize <JoinOrCreateGameSessionResponse>();
                    //Test if to run or wait
                    _CurrentGameSessionId = jcr.GameSessionId;
                    if (jcr.start)
                    {
                        int cnt = jcr.SessionPlayers.Count;
                        if (OnStartSession != null)
                        {
                            OnStartSession(jcr.SessionPlayers);
                        }
                    }
                    else
                    {
                        //used for single instance debug
                        //Create second request and link to same session enable single instance tests
                        //JoinOrCreateGameSessionRequest jcrr = new JoinOrCreateGameSessionRequest();
                        //jcrr.UserId = _UserId;
                        //m_client.Invoke("Que", jcrr.CreateRequest( RequestProcessorEnum.JoinOrCreateGame, _UserId).Serialize());
                    }
                }
                break;

                case RequestProcessorEnum.StartRound:
                {
                    StartRoundResponse srr = response.JsonPayload.Deserialize <StartRoundResponse>();
                    if (OnStartRound != null)
                    {
                        OnStartRound(srr.TankId, srr.RoundNum);
                    }
                }
                break;

                case RequestProcessorEnum.BeginRound:
                {
                    BeginRounResponse brr = response.JsonPayload.Deserialize <BeginRounResponse>();
                    if (OnRoundBegins != null)
                    {
                        OnRoundBegins(brr.RoundNum);
                    }
                }
                break;

                case RequestProcessorEnum.GetCanStartRound:
                {
                    CanStartRoundResponse crr = response.JsonPayload.Deserialize <CanStartRoundResponse>();
                    if (OnRoundBegins != null)
                    {
                        OnRoundBegins(crr.RoundNum);
                    }
                }
                break;

                default:
                    break;
                }
            }
            if (response.Kind != (int)RequestProcessorEnum.TankPosition)
            {
                UnityEngine.Debug.Log(response.Kind.ToString() + " time:" + response.TimeTaken.ToString() + " total calls:" + _recievedResonses.ToString() + " Json:" + response.JsonPayload);
            }
            //UnityEngine.Debug.Log(response.Kind.ToString() + " time:" + response.TimeTaken.ToString() + " Json:" + response.JsonPayload);
        }
Example #6
0
        public NegotiatedContentResult <UserExistsResponse> PostUserExists([FromBody] UserExistsRequest request)
        {
            UserExistsResponse resp = _userServices.CheckUserExists(request);

            return(Content(HttpStatusCode.OK, resp));
        }