Exemple #1
0
 /// <summary>
 /// 게임 시작 요청
 /// </summary>
 /// <param name="request"></param>
 /// <param name="responseStream"></param>
 /// <param name="context"></param>
 /// <returns></returns>
 public override async Task StartPlay(StartPlayRequest request, IServerStreamWriter <StartPlayReply> responseStream, ServerCallContext context)
 {
     try
     {
         //await SequentialMatchmaking.StartPlay(request, responseStream, context);
         await RankMatchmaking.StartPlay(request, responseStream, context);
     }
     catch (Exception ex)
     {
         Log.Error($"StartPlay error {ex.ToString()}");
         var reply = new StartPlayReply();
         reply.Code    = ErrorCode.NotEnough;
         reply.IsStart = false;
         reply.CharacterList.Add(new StartPlayCharacterInfo()); // 자신포함으로 빈슬롯 한개 넣어줌
         await responseStream.WriteAsync(reply);
     }
 }
Exemple #2
0
        /// <summary>
        /// 로그인
        /// </summary>
        /// <param name="request"></param>
        /// <param name="responseStream"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override async Task Login(LoginRequest request, IServerStreamWriter <LoginReply> responseStream, ServerCallContext context)
        {
            try
            {
                Log.Information($"login player ID:{request.PlayerId}");
                if (request.PlayerId != "")
                {
                    // 유저 아이디 영문과 숫자 조합만 허용
                    //if (Regex.IsMatch(request.UserId, @"^[a-zA-Z0-9]+$") == false)
                    //{
                    //    Log.Error($"login error {request.UserId}");

                    //    await responseStream.WriteAsync(new LoginReply() { Code = ErrorCode.WrongLetters });
                    //    return;
                    //}
                }

                var(ret, responseValidate) = await WebAPIClient.Web.validate(request.PlayerId, request.AccessToken);

                if (ret == false)
                {
                    Log.Error($"Login auth error player_id:{request.PlayerId}, peer:{context.Peer}");

                    // IDP 인증 실패시 로그인 실패처리 할 것인지
                    if (context.Peer.Contains("203.246.171.143") == true)
                    {
                        Log.Warning($"Login auth white list :{request.PlayerId}");
                    }
                    else if (ServerConfiguration.Instance.EnableCheckAccessToken)
                    {
                        await responseStream.WriteAsync(new LoginReply()
                        {
                            Code = ErrorCode.Auth
                        });

                        return;
                    }
                }

                // todo : 클라이언트로 부터 맴버 초기값 세팅이 필요.
                Models.Member member = new Models.Member()
                {
                    device_model_name = "",
                    os_version        = "",
                    language_code     = responseValidate == null ? "" : responseValidate.lang,
                    nation_code       = responseValidate == null ?  "" : responseValidate.country,
                    create_time       = DateTime.UtcNow,
                };

                (var session, var err, var player_id) = await Session.LoginSession(context.Peer, request.PlayerId, request.DeviceUniqueIdentifier, true, member);

                if (session == null)
                {
                    Log.Error("login {0}", context.Peer);

                    await responseStream.WriteAsync(new LoginReply()
                    {
                        Code = err
                    });

                    return;
                }

                bool           IsPlaying;
                StartPlayReply ReloadStartPlay = null;
                long           match_id;
                if (ServerConfiguration.Instance.gameSetting.EnableReJoin)
                {
                    (IsPlaying, ReloadStartPlay, match_id) = await RankMatchmaking.RestoreMatchUser(session);
                }
                else
                {
                    IsPlaying = false;
                }

                Log.Information($"login user_no:{session.user_no}, player_id:{player_id}, session_id:{session.session_id}, user_name:{session.user_name}, IsPlaying:{IsPlaying}, ReloadStartPlay:{ReloadStartPlay?.BattleServerAddr}");

                var reply = new LoginReply();
                reply.UserId          = player_id;
                reply.SessionId       = session.session_id;
                reply.Code            = ErrorCode.Success;
                reply.IsPlaying       = IsPlaying;
                reply.ReloadStartPlay = ReloadStartPlay;
                reply.JsonData.Add(JsonData.Instance.OriginalData);
                reply.UserName   = session.user_name ?? "";
                reply.ServerTime = DateTime.UtcNow.ToTimestamp();

                await responseStream.WriteAsync(reply);

                History.Info(session.member_no, session.user_no, session.character_no, HistoryLogAction.Login, (byte)HistoryLogReason.None, 0, 0, request.PlayerId, session.user_name);
            }
            catch (Exception ex)
            {
                Log.Error($"Login error {ex.ToString()}");
            }
        }