progress
This commit is contained in:
parent
9ef43bb9f6
commit
0a4b8ebeb2
14 changed files with 157 additions and 28 deletions
|
@ -152,7 +152,7 @@ namespace SignalRChat.Hubs
|
|||
_dbContext.SessionUsers.Add(userSession);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
var usersSession = _dbContext.SessionUsers.Where(m => m.SessionId == session.SessionId).Select(m => m.UserId).ToList();
|
||||
//var usersSession = _dbContext.SessionUsers.Where(m => m.SessionId == session.SessionId).Select(m => m.UserId).ToList();
|
||||
// var players = _datacontext.
|
||||
// Users.
|
||||
// Where(m => usersSession.Contains(m.Id)).ToList().
|
||||
|
@ -165,17 +165,20 @@ namespace SignalRChat.Hubs
|
|||
// Position = new Tile { X = 0, Y = 0 }
|
||||
// }).ToList();
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
//await _dbContext.SaveChangesAsync();
|
||||
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, sessionName);
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, session.SessionName);
|
||||
var user = _datacontext.Users.First(u => u.Id == userId);
|
||||
var SessionUsers = _dbContext.SessionUsers.Where(m => m.SessionId == session.SessionId).OrderBy(m => m.UserId).ToList();
|
||||
var player = new Player { UserId = userId, Initials = user.Initials, Position = new Tile { X = 0, Y = 0 }, Color = Colors[SessionUsers.IndexOf(SessionUsers.FirstOrDefault(m => m.UserId == userId))] };
|
||||
var u = SessionUsers.FirstOrDefault(m => m.UserId == userId);
|
||||
var player = new Player { UserId = userId, Initials = user.Initials, Position = new Tile { X = 0, Y = 0 }, Color = Colors[SessionUsers.IndexOf(u)] };
|
||||
|
||||
await Clients.Group(sessionName).NewPlayer(player);
|
||||
|
||||
var newSession = new Sledgemapper.Shared.Entities.Session
|
||||
{
|
||||
SessionName = sessionName
|
||||
SessionName = sessionName,
|
||||
SessionId = session.SessionId
|
||||
};
|
||||
|
||||
return newSession;
|
||||
|
@ -199,11 +202,11 @@ namespace SignalRChat.Hubs
|
|||
// }
|
||||
}
|
||||
|
||||
public async Task UpdatePosition(string sessionName, Tile tile)
|
||||
public async Task UpdatePosition(string sessionName,int sessionId, Tile tile)
|
||||
{
|
||||
var userId = int.Parse(Context.User.Identity.Name);
|
||||
var session = _dbContext.Sessions.FirstOrDefault(m => m.SessionName == sessionName);
|
||||
var SessionUsers = _dbContext.SessionUsers.Where(m => m.SessionId == session.SessionId).OrderBy(m => m.UserId).ToList();
|
||||
//var session = _dbContext.Sessions.FirstOrDefault(m => m.SessionName == sessionName);
|
||||
var SessionUsers = _dbContext.SessionUsers.Where(m => m.SessionId == sessionId).OrderBy(m => m.UserId).ToList();
|
||||
var user = _datacontext.Users.First(u => u.Id == userId);
|
||||
var player = new Player { UserId = userId, Initials = user.Initials, Position = tile, Color = Colors[SessionUsers.IndexOf(SessionUsers.FirstOrDefault(m => m.UserId == userId))] };
|
||||
await Clients.Group(sessionName).PlayerUpdate(player);
|
||||
|
@ -242,6 +245,7 @@ namespace SignalRChat.Hubs
|
|||
{
|
||||
_dbContext.UserConnections.Remove(userConnection);
|
||||
}
|
||||
|
||||
var userSessions = _dbContext.SessionUsers.Where(m => m.UserId == userConnection.UserId).ToList();
|
||||
{
|
||||
foreach (var userSession in userSessions)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue