Example #1
0
        public void LDCMsg_GetProfile(Msg.LDCBaseMsg msg)
        {
            var ldcData = msg as Msg.LDCMsg_GetProfile;

            UriData uriData;

            uriData             = GetUriData(ApiUriType.GetProfile);
            uriData.accessToken = ldcData.accessToken;

            var result = RequestResult(uriData);

            if (!string.IsNullOrEmpty(result))
            {
                var respones = JsonConvert.DeserializeObject <Respones_GetProfile>(result);

                var intlMsg = new InternalMsg.IntlMsg_GetProfile()
                {
                    guid = ldcData.guid,

                    userId        = respones.userId,
                    displayName   = respones.displayName,
                    pictureUrl    = respones.pictureUrl,
                    statusMessage = respones.statusMessage
                };

                NetServer.InternalHandleMessageByGuid(intlMsg);
            }
            else
            {
                logger.Warn($"HttpRequest fail Uid={msg.guid}");
            }
        }
        public void Login(InternalMsg.IntlMsg_GetProfile profile)
        {
            logger.Debug($"Profile UserId={profile.userId} displayName={profile.displayName}");

            displayName   = profile.displayName;
            pictureUrl    = profile.pictureUrl;
            statusMessage = profile.statusMessage;

            if (stateType == UserStateType.None)
            {
                var repoUser = TCGGameSrv.IocContainer.Resolve <Repository.IUser>();

                tblUser = repoUser.GetUserFromLineUserId(profile.userId);
                var IsCreate = false;
                if (null == tblUser)
                {
                    Table.TblUser newUser = new Table.TblUser()
                    {
                        lineuserid = profile.userId,
                        nickname   = string.Empty,
                        address    = string.Empty,
                        regDate    = DateTime.Now
                    };

                    newUser.uuid = repoUser.Insert(newUser);
                    tblUser      = newUser;
                    IsCreate     = true;
                }

                if (IsCreate)
                {
                    stateType = UserStateType.NewUserConnect;

                    LBD.LBDApiManager.Instance.AddLBDCmd(new LBD.Msg.LBDMsg_MultiMintNonFungible()
                    {
                        uid      = UID,
                        guid     = Id.ToString(),
                        toAddr   = string.Empty,
                        toUserId = lineUID,
                        mints    = DefaultCardToTokenTypeInfo()
                    });

                    IsCreate = false;
                    logger.Debug($"UserUID={UID} UserStateType={stateType.ToString()}");
                }
                else
                {
                    if (string.IsNullOrEmpty(tblUser.nickname))
                    {
                        stateType = UserStateType.CreateNickName;

                        var ackData = new TcpMsg.AckVerifyAccessToken();
                        ackData.authType = TcpMsg.AuthType.CreateNickname;

                        Send(new Packet(ackData));
                    }
                    else
                    {
                        stateType = UserStateType.ExistingUserConnect;
                        GetWalletAddress();
                    }
                }

                logger.Debug($"UserUID={UID} UserStateType={stateType.ToString()}");
            }
        }