Пример #1
0
        public override Task OnConnected()
        {
            string name = Context.QueryString["username"];

            _connections.Add(name, Context.ConnectionId);

            _logger.Info($"{name} has entered the chat room");

            return(base.OnConnected());
        }
Пример #2
0
        public async Task SubscribeToNetwork(string networkId, int eventType)
        {
            //TODO: user provider, add network identity to user
            await _connectionMapping.Add(Guid.Parse(networkId), 0, Context.ConnectionId);

            await Clients.Client(Context.ConnectionId).SendAsync("onSubscripted", "success");
        }
Пример #3
0
        public override Task OnConnectedAsync()
        {
            var connectionId = Context.ConnectionId;
            var email        = Context.User.Identity.Name;

            // TODO: условие нужно потому что еще нет авторизации по сокетам
            if (!string.IsNullOrEmpty(email))
            {
                _connectionMapping.Add(email, connectionId);
            }

            return(base.OnConnectedAsync());
        }
Пример #4
0
        //Online status
        public override Task OnConnectedAsync()
        {
            var curentUserId = Context.User.Identity.Name;
            var count        = connections.GetConnections(curentUserId).Count();

            if (count == 0)
            {
                Clients.All.SendAsync("ReciveConnectedStatus", curentUserId);
            }

            connections.Add(curentUserId, Context.ConnectionId);

            return(base.OnConnectedAsync());
        }
Пример #5
0
        //[AllowAnonymous]
        public override async Task OnConnectedAsync()
        {
            var identity     = Context.User.Identity;
            var connectionId = Context.ConnectionId;

            if (identity.IsAuthenticated)
            {
                try
                {
                    await _connectionMapping.Add(connectionId);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
                await Groups.AddToGroupAsync(Context.ConnectionId, groupName : (identity.Name)).ConfigureAwait(false);
            }

            //await base.OnConnectedAsync();
        }
Пример #6
0
 /// <summary>
 /// Registers the name of the user.
 /// </summary>
 /// <returns>The user name.</returns>
 /// <param name="userName">User name.</param>
 public Task RegisterUserName(string userName)
 {
     _connectionMapping.Add(Context.ConnectionId, new ConnectionUser(userName));
     return(Clients.Client(Context.ConnectionId).SendAsync("CommandSend", new ChatMessage("Bot", "Successfully Registered! :)")));
 }
Пример #7
0
        public async Task AddOrCreate(string key, int eventType, string connId)
        {
            var ex = await Record.ExceptionAsync(() => _connectionMapper.Add(Guid.Parse(key), eventType, connId));

            Assert.Null(ex);
        }