fixed chatservice
This commit is contained in:
parent
3af5a0d107
commit
febc4d9488
2 changed files with 7 additions and 9 deletions
|
|
@ -49,7 +49,6 @@ public class ChatService
|
||||||
|
|
||||||
var user = Users.First(p => p.Key.Uid == session.Uid);
|
var user = Users.First(p => p.Key.Uid == session.Uid);
|
||||||
user.Value.Add(session.Id);
|
user.Value.Add(session.Id);
|
||||||
|
|
||||||
user.Key.Online = true;
|
user.Key.Online = true;
|
||||||
|
|
||||||
_logger.LogInformation($"Chat ({user.Key.Username} / {session.Id}) added");
|
_logger.LogInformation($"Chat ({user.Key.Username} / {session.Id}) added");
|
||||||
|
|
@ -80,8 +79,6 @@ public class ChatService
|
||||||
_logger.LogInformation($"Chat ({user.Key.Username} / {session.Id}) removed");
|
_logger.LogInformation($"Chat ({user.Key.Username} / {session.Id}) removed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.Value.Any()) return;
|
|
||||||
|
|
||||||
user.Key.Online = false;
|
user.Key.Online = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -66,27 +66,28 @@ public class SessionHandler : CircuitHandler
|
||||||
{
|
{
|
||||||
_logger.LogInformation($"Session up: {circuit.Id}");
|
_logger.LogInformation($"Session up: {circuit.Id}");
|
||||||
|
|
||||||
|
await base.OnConnectionUpAsync(circuit, cancellationToken);
|
||||||
|
|
||||||
State.Connected = true;
|
State.Connected = true;
|
||||||
|
|
||||||
await UpdateStateAsync(cancellationToken);
|
await UpdateStateAsync(cancellationToken);
|
||||||
await base.OnConnectionUpAsync(circuit, cancellationToken);
|
|
||||||
|
|
||||||
await _sessionPool.UpdateAsync(State, cancellationToken);
|
|
||||||
await _chatService.AddAsync(State, cancellationToken);
|
await _chatService.AddAsync(State, cancellationToken);
|
||||||
|
await _sessionPool.UpdateAsync(State, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task OnConnectionDownAsync(Circuit circuit, CancellationToken cancellationToken)
|
public override async Task OnConnectionDownAsync(Circuit circuit, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
_logger.LogInformation($"Session down: {circuit.Id}");
|
_logger.LogInformation($"Session down: {circuit.Id}");
|
||||||
|
|
||||||
State.Connected = false;
|
|
||||||
|
|
||||||
await base.OnConnectionDownAsync(circuit, cancellationToken);
|
await base.OnConnectionDownAsync(circuit, cancellationToken);
|
||||||
|
|
||||||
_httpContextAccessor?.HttpContext?.Abort();
|
State.Connected = false;
|
||||||
|
|
||||||
await _sessionPool.UpdateAsync(State, cancellationToken);
|
|
||||||
await _chatService.RemoveAsync(State, cancellationToken);
|
await _chatService.RemoveAsync(State, cancellationToken);
|
||||||
|
await _sessionPool.UpdateAsync(State, cancellationToken);
|
||||||
|
|
||||||
|
_httpContextAccessor?.HttpContext?.Abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateStateAsync(Circuit circuit, CancellationToken cancellationToken)
|
public async Task UpdateStateAsync(Circuit circuit, CancellationToken cancellationToken)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue