Exemplo n.º 1
0
 public static void SetAccessToken(this HubCallerContext context, string accessToken)
 {
     context.Items.Add("access_token", accessToken);
 }
Exemplo n.º 2
0
 public SomeSubscriptionObject Build(HubCallerContext context)
 {
     // Logic to build
     return(new SomeSubscriptionObject());
 }
Exemplo n.º 3
0
 public static bool IsAuthenticated(this HubCallerContext context)
 {
     return(context.User.Identity.IsAuthenticated);
 }
Exemplo n.º 4
0
 public Task <Exception> OnException(HubCallerContext context, Exception exception)
 {
     _trace($"[dotNetify] connId={context.ConnectionId} {exception.GetType().Name}={exception.Message}");
     return(Task.FromResult(exception));
 }
 public AWSSockerServiceHub(HubCallerContext hubCallerContext, IGroupManager groups, IHubClients clients)
 {
     _hubCallerContext = hubCallerContext;
     _groups           = groups;
     _clients          = clients;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Handles disconnected event by removing the headers associated with the connection from the cache.
 /// </summary>
 /// <param name="context">SignalR hub context.</param>
 public Task OnDisconnected(HubCallerContext context)
 {
     _headersCache.Remove(_headersKey(context.ConnectionId));
     return(Task.CompletedTask);
 }
Exemplo n.º 7
0
 public static string GetViewModelGroupName(this HubCallerContext context)
 {
     return(context.Items.ContainsKey(s_viewModelGroupNameKey)
     ? (string)context.Items[s_viewModelGroupNameKey]
     : null);
 }
 public Task OnDisconnected(HubCallerContext context)
 {
     Invoked?.Invoke(this, context);
     return(Task.CompletedTask);
 }
Exemplo n.º 9
0
 public ResponseHubCallerContext(HubCallerContext context)
 {
     _context = context;
     _items   = new Dictionary <object, object>(context.Items);
 }
 public string GetPictureUrl(HubCallerContext context)
 {
     return(context.User.FindFirstValue("picture"));
 }
Exemplo n.º 11
0
 public PlayerInfo(string name, HubCallerContext ctx)
 {
     Name            = name;
     ConnectionId    = ctx.ConnectionId;
     DisconnectToken = ctx.ConnectionAborted;
 }
 public string GetUsername(HubCallerContext context)
 {
     return(context.User.FindFirstValue("name") ??
            context.User.FindFirstValue(ClaimTypes.Name) ??
            GetUserId(context));
 }
 public string GetUserId(HubCallerContext context)
 {
     return(context.UserIdentifier ??
            throw new UnauthorizedAccessException("Cannot obtain user identifier"));
 }
Exemplo n.º 14
0
 internal HubInvocationContext(ObjectMethodExecutor objectMethodExecutor, HubCallerContext context, IServiceProvider serviceProvider, Hub hub, object?[] hubMethodArguments)
     : this(context, serviceProvider, hub, objectMethodExecutor.MethodInfo, hubMethodArguments)
 {
     ObjectMethodExecutor = objectMethodExecutor;
 }
Exemplo n.º 15
0
        public async Task Enlist(HubCallerContext context)
        {
            await Task.Delay(0);

            Enlist(context, null);
        }
Exemplo n.º 16
0
 private bool ProcessParameter(HubCallerContext context)
 {
     return(string.IsNullOrEmpty(context.QueryString["server"]) ? false : Convert.ToBoolean(context.QueryString["server"]));
 }
Exemplo n.º 17
0
        public async Task Delist(HubCallerContext context, bool stopCalled)
        {
            await Task.Delay(0);

            _clients.Remove(context.ConnectionId);
        }
Exemplo n.º 18
0
 public Task LogoutAsync(HubCallerContext context)
 {
     _users.TryRemove(context.ConnectionId, out var _);
     SetUser(context, _guest);
     return(Task.CompletedTask);
 }
Exemplo n.º 19
0
 public static HttpRequest GetHttpRequest(this HubCallerContext context)
 {
     return(context.GetHttpContext().Request);
 }
Exemplo n.º 20
0
 public void ReceiveScripts(string correlationId, string contextConnectionId, string script, HubCallerContext context, IGroupManager groups, IHubCallerConnectionContext <dynamic> clients)
 {
     this.MessagesReceived.Add(
         new TestMessageModel
     {
         Script = script
     });
 }
Exemplo n.º 21
0
 public Task OnDisconnected(HubCallerContext context)
 {
     _trace($"[dotNetify] connId={context.ConnectionId} type=OnDisconnected");
     return(Task.CompletedTask);
 }
Exemplo n.º 22
0
 public void ReceiveInGroupManager(string correlationId, string operation, string userId, string message, HubCallerContext context, IHubCallerConnectionContext <dynamic> clients, IGroupManager groups)
 {
     this.MessagesReceived.Add(
         new TestMessageModel
     {
         UserId  = userId,
         Message = message
     });
 }
Exemplo n.º 23
0
 public virtual async Task AddSessionAsync(HubCallerContext context, HubGroup group, string subGroup)
 {
     await _context.Groups.AddToGroupAsync(context.ConnectionId, $"{group.ToString()}/{subGroup}");
 }
Exemplo n.º 24
0
 public async Task RequestScripts(SignalX SignalX, HubCallerContext context, IHubCallerConnectionContext <dynamic> clients, IGroupManager groups, string correlationId)
 {
     correlationId = correlationId ?? Guid.NewGuid().ToString();
     await SignalX.RespondToScriptRequest(correlationId, context, clients, groups).ConfigureAwait(false);
 }
Exemplo n.º 25
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public T Build(HubCallerContext context)
 {
     return(null);
 }
Exemplo n.º 26
0
 public string GetName(HubCallerContext context)
 => context.ConnectionId;
Exemplo n.º 27
0
        public int CountMessagesByTimeSec(int sec, HubCallerContext hubCallerContext)
        {
            int count = this.Messages.Where(p => p.MessageDate > DbFunctions.AddSeconds(DateTime.Now, -sec)).Where(p => p.Name == hubCallerContext.User.Identity.Name).Count();

            return(count);
        }
Exemplo n.º 28
0
 public bool IsAdmin(HubCallerContext hubCallerContext)
 {
     return(hubCallerContext.User.IsInRole("admin"));
 }
Exemplo n.º 29
0
 public static string GetIPAddress(this HubCallerContext context)
 {
     return(context.Request.GetHttpContext().Request.GetIPAddress());
 }
Exemplo n.º 30
0
 public static string GetAccessToken(this HubCallerContext context)
 {
     return(context.Items["access_token"].ToString());
 }