code format

This commit is contained in:
2019-06-12 11:17:07 +01:00
parent cebb2caeb2
commit d32b088497

View File

@ -88,11 +88,11 @@ namespace Yavsc
Connected = true
});
_dbContext.SaveChanges();
Clients.Group(Constants.HubGroupFollowingPrefix+userId).notifyuser(NotificationTypes.Connected, userName, null);
Clients.Group(Constants.HubGroupFollowingPrefix + userId).notifyuser(NotificationTypes.Connected, userName, null);
foreach (var uid in _dbContext.CircleMembers.Select(m => m.MemberId))
{
await Groups.Add(Context.ConnectionId, Constants.HubGroupFollowingPrefix+uid);
await Groups.Add(Context.ConnectionId, Constants.HubGroupFollowingPrefix + uid);
}
}
else
@ -105,7 +105,7 @@ namespace Yavsc
{
await Groups.Add(Context.ConnectionId, Constants.HubGroupAnonymous);
}
await base.OnConnected();
await base.OnConnected();
}
string setUserName()
{
@ -129,10 +129,11 @@ namespace Yavsc
public override Task OnDisconnected(bool stopCalled)
{
string userName = Context.User?.Identity.Name;
if (userName!=null) {
if (userName != null)
{
var user = _dbContext.Users.FirstOrDefault(u => u.UserName == userName);
var userId = user.Id;
Clients.Group(Constants.HubGroupFollowingPrefix+userId).notifyuser(NotificationTypes.DisConnected, userName, null);
Clients.Group(Constants.HubGroupFollowingPrefix + userId).notifyuser(NotificationTypes.DisConnected, userName, null);
var cx = _dbContext.ChatConnection.SingleOrDefault(c => c.ConnectionId == Context.ConnectionId);
if (cx != null)
@ -343,7 +344,11 @@ namespace Yavsc
[Authorize]
public void SendPV(string userName, string message)
{
if (string.IsNullOrWhiteSpace(userName)) return;
if (string.IsNullOrWhiteSpace(userName))
{
Clients.Caller.notifyUser(NotificationTypes.Error, "none!", "specify an user.");
return;
}
if (userName[0] != '?')
if (!Context.User.IsInRole(Constants.AdminGroupName))
@ -380,8 +385,8 @@ namespace Yavsc
void Abort()
{
string cxId;
if (!ChatUserNames.TryRemove(Context.ConnectionId, out cxId ))
string cxId;
if (!ChatUserNames.TryRemove(Context.ConnectionId, out cxId))
_logger.LogError($"Could not remove user cx {Context.ConnectionId}");
}