Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR 2.0.2 Creating PersistentConnection

I installed SignalR 2.0.2 to my MVC 4.5 Application by using package manager console. And I did the standard example for the connection configuration.

namespace SignalRPersistent
{

    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR("/echo");
        }
    }
}

The problem is MapSignalR method does not accept string, while compiling the error says that

Argument type string is not assignable to parameter type SignalRHubConfiguration. But I can see an overload method that accepts a string but it insists not to be compiled. What can be problem ?

like image 322
Barış Velioğlu Avatar asked Feb 02 '14 15:02

Barış Velioğlu


People also ask

How to add the SignalR library to your application?

But no need to worry, there is another way to add the SignalR Library to your application. The following are the steps for installing the library to your application. Click on "File" and Select "New Project". The "New Project" window opens up. In the left panel, select your preferred language and select "Web".

How does a SignalR connection work?

A SignalR connection starts as HTTP, and is then promoted to a WebSocket connection if available.

How do I create a statisticshub in SignalR?

In the Add New Item dialog box, select the Visual C# | Web | SignalR node in the left pane, select SignalR Hub Class (v2) from the center pane, name the file StatisticsHub.cs and click Add. Replace the code in the StatisticsHub class with the following code.

How does SignalR send the method names and parameter values?

When the method call executes, SignalR sends the method name and the parameter values to the client. If the client has a method that matches the name, that method is called and the parameter values are passed to it.


1 Answers

I changed the code like below and I started to work.

app.MapSignalR<ConnectionHub>("/echo");

ConnectionHub is the class that inherit from PersistentConnection. The examples on the internet does not require to specify the class but they didnt work for me.

like image 76
Barış Velioğlu Avatar answered Oct 31 '22 09:10

Barış Velioğlu