I have used SignalR
to achieve real-time messaging functionality in several of my projects. It seems to work reliably and is very easy to learn to use.
The temptation, at least for me, is to abandon developing a Web API service and use SignalR
for everything.
I feel like this could be achieved by thoughtful design, and if it were, it would mean far less client code would be necessary. More importantly, it would mean that there would be a single interface to services rather than a split interface, and in the worst case, that one could wire this up without thinking about when things get rendered, etc.
So, I would like to know:
- Is there any other reason not to use SignalR in lieu of all web services besides performance?
- Is SignalR's performance sufficiently concerning that it would not make sense to do so?
It has long been a dream of mine to be able to translate server-side object and service definitions to client-side service access code without something silly like node.js
. For instance, if I define an interesting object InterestingObject
and a service to CRUD
the object InterestingObjectService
, I can define a standard URL route to the service - say, "/{serviceName}/{methodName}" - but I still need to write client code to access the service. Since the object is going to be passed from client to server and back, there is no practical reason to have to define the object explicitly in client-side code, nor should there be a need to explicitly define the routes to perform CRUD operations. I feel like there should be a way to standardize all of this so that it is possible to write a client under the assumption that service access works from the client to the server and back as transparently as it would if I were writing a WinForms or Java Applet or Native App or what have you.
If SignalR is good enough to use in lieu of a traditional web service, it may be a viable way to achieve this. SignalR already includes functionality to make the hub work like service I describe, so I could define a common base (CRUD) service that would offer all of this functionality out-of-the-box with some reflection. Then I could almost take for granted the service access, saving me the annoyance of re-writing code to access something that could be accessed by convention - and more importantly, the time I would have to spend writing code to define how this is updated in the DOM.
After reading my edit I feel like it may be a little nonsensical so please feel free to ask me if you have questions about what I am getting at. Basically, I want the service access to be as transparent as possible.