public bool Create(StreamSimpleModel model) { try { var any = _streamUserMapper.Any(model.StreamId); if (any) { Logger.Warn("Stream exist!" + model); return(false); } foreach (var connection in _connectionMapper.GetConnections(CurUserId)) { Groups.Add(connection, model.StreamId); } _streamUserMapper.Add(model.StreamId, CurUserId); _streamCreatorMapper.Add(Context.ConnectionId, model.StreamId); Logger.Debug(LogKey + model); return(true); } catch (Exception e) { Logger.Error(e); return(false); } }
public async Task Subscribe() { //user unique identifier string identifier = Context.UserIdentifier; //check if that identifier is already in list of connections if (!_connections.GetConnections(identifier).Contains(Context.ConnectionId)) { _connections.Add(identifier, Context.ConnectionId); } int connections = _connections.GetTotalConnections(); await Clients.All.CreateNotificationForLogin(connections); }
public override Task OnConnected() { try { var isOnline = _mapper.Any(CurUserId); _mapper.Add(CurUserId, Context.ConnectionId); InitChatsAndInform(isOnline); if (Config.Instance.InformBackendOnlineOffline) { Task.Run(() => _backend.SetOnline(WorkerContext, CurUserId)); } Logger.Debug(LogKey); } catch (Exception e) { Logger.Error(e); } return(base.OnConnected()); }