I'm developing an ASP.NET MVC app that is consumed by both by JavaScript in the browser and by a native Android app, and I wish to use SignalR. This is of course no problem in the browser, but I do not know how to interface from the Android app.
Are my only options:
In this article, we are going to learn the fundamentals of SignalR and its client. SignalR is a new developer's API provided for ASP.NET Web Applications by Microsoft. It used to add "real time" Web functionality to ASP.NET Applications. "Real Time" Web functionality is the ability of a Server code to push the contents to the connected clients.
ASP.NET SignalR is a library for ASP.NET developers that simplifies the process of adding real-time web functionality to applications.
In typical web applications, the communication flow is one-way, i.e. from client to the server. The client initiates a request to the server, the server performs some task, and sends the response to the client. SignalR is an open-source project that enables real-time, bi-directional web communication from server to clients.
Any class that is Inherited from HUB class is a SignalR Hub.Hub is a Server side material and needs to be hosted. For .NET, we have 2 clients that is (jQuery client and have ASP.NET client). So from here we will check how we can work with signalR.
I was also searching for a SignalR-client for Android, but i didnt find one so I started to develop one by myself. You can checkit out at https://github.com/erizet/SignalA. Curently it's more like a proof-of-concept than a finnished library.
It's now updated to protocol version 1.2 which is used in the 1.0 release of SignalR.
I'm unaware of any Java based implementation that you could use in an Android application right now. So I think you're looking at option #2.
Java certainly has the core functionality needed to to be able to communicate with at least the long-polling transport implementation of SignalR pretty easily. You'd just be looking at combining HttpClient
with org.json
.
Host a hidden webview in your application and use the script bridge to talk to it. Use the javascript signalr libraries in your webview.
If HTML5-based Android app is an option, you can try using native SignalR JavaScript client. Works flawlessly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With