AspNetCore 2.0 + signalR 1.0.0 alpha2 add pipeline or middleware

1k views Asked by At

In an older version of SignalR and .NetFreamwork i used the class inherit the class HubPipelineModule like :

public class IsConnectedPipeLine : HubPipelineModule
{
    protected override bool OnBeforeIncoming(IHubIncomingInvokerContext context)
    {
        if (context.MethodDescriptor.Name == "GetToken")
            return true;
        return ChatIdentity.CheckToken(context.Hub.Context.GetCurrentUserToken());
    }
}

Now i want to start developing in .NetCore 2.0 and SignalR 1.0.0 alpha 2 but I do not know how to implement pipe line, middleware or something like costum ActionAttribute in Web API controller, i do not care how, basically i need the OnBeforeIncoming functionality.

I searched and found only this article but it is very old and not for new versions.

1

There are 1 answers

0
Jody Sowald On

Summarizing what is listed here and where this chain of posts leads.

Here is the proposal that was eventually created and used for net core signalr for similar effect to the HubPipelineModule

and here is a link to documentation on it

and if you're curious... Here's documentation on filters in general

If you're like me, you'll find this section particularly helpful for writing your own filters

Exception catching filters

In my own experience I had a lil scare figuring out how to use it, since I was on net core 3.1 instead of 5.0. 5.0 has the AddFilter call available.