Exemple #1
0
        public async Task LoginUser(UserData user)
        {
            if (user.Name != "" && user.Password != "")
            {
                (ListOf_DBResult flag, User dataUser) = await HoloData.LoginUser(new User()
                {
                    Name = user.Name, Password = user.Password
                });

                if (connectedUsers.ContainsKey(Context.ConnectionId))
                {
                    if (flag == ListOf_DBResult.Success)
                    {
                        connectedUsers[Context.ConnectionId].SessionToken = dataUser.SessionToken.ToString();
                        UpdateModel updateModel = new UpdateModel();
                        updateModel.AddUser(dataUser);
                        await Clients.Caller.SendAsync("ServerLogin", flag, updateModel);

                        System.Console.WriteLine($"Connected User: {Context.ConnectionId}");
                        System.Console.WriteLine($"Session Token: {dataUser.SessionToken}");
                    }
                    await Clients.Caller.SendAsync("ServerLogin", flag);
                }
                else
                {
                    System.Console.WriteLine("Bad Client Token");
                }
            }
        }
Exemple #2
0
        public async Task CreateUser(UserData user)
        {
            (ListOf_DBResult flag, User dataUser) = await HoloData.CreateUser(new User()
            {
                Name = user.Name, Password = user.Password
            });

            if (flag == ListOf_DBResult.Success)
            {
                if (connectedUsers.ContainsKey(Context.ConnectionId))
                {
                    connectedUsers[Context.ConnectionId].SessionToken = dataUser.SessionToken.ToString();
                    UpdateModel updateModel = new UpdateModel();
                    updateModel.AddUser(dataUser);
                    await Clients.Caller.SendAsync("ServerLogin", flag, updateModel);
                }
            }
            await Clients.Caller.SendAsync("ServerLogin", flag);
        }