Realtime notification using signalR - dashboard

I am new to SignalR. I am hoping to integrate SignalR to send notification in dashboard (i.e. latest applications created by staff) so that new applications will be shown without refreshing the dashboard. Applications should be fetched from a database (sql server) and notified to the dashboard. Is there any sample that I can look in to and take some idea how to start on this? Any help is highly appreciated.
Regards
Samitha

Sounds cut and dry. You want to create a Hub which your dashboard clients can connect to to receive updates. Then either the Hub itself could have a monitoring routine (e.g. background thread that is watching some stream of events from some external resource) that is pushing out updates to the connected clients.
Alternatively you could go with a better separation and just have the Hub be "dumb" and move the monitoring/notification off into another background process which just connects to the Hub like any other client and just pushes its notifications to the other clients through the Hub.
I would highly recommend just reading the Wiki and taking a look at some of the samples that come with the SignalR solution.

Related

How to build real time notifications in a distributed project?

I wonder to know which technique and tools I should use to have the ability to send real time notifications to users. Specifically if I build a messaging system.
I can see that modern social networks can send notifications about new messages almost immediately. Even when the user 'A' from one country writes a message to the user 'B' in another country you can see that the user 'A' writes a message and you immediately see it (even if those users live in different continents).
I tried to figure out how it is possible and find any information about this but without success.
The only thing I found out is the technique when we use a Redis or RabbitMQ server with several servers which acts like publishers and subscribers. Our API servers receive new messages then they push a new message in the queue then subscribers receives the messages and if they have an open WebSocket with the recipient they push this message in the WebSocket and a client receives the message.
But it really won't work if you have a distributed project and your clients are connected to the nearest servers in the nearest data center.
The question is: what technologies/techniques/anything we should use to be able to build notifications in a distributed project?
If you develop your distributed app/system using web technologies, you can consider building what is referred to as a Progressive Web App. With PWAs you can add push notifications in a relatively easy way. You could start with a PWA approach, and then decide later on if developing a native app as well (i.e. iOS or Android) would be necessary.
There are many resources to learn and guide you in developing progressive web apps. Check the references I mentioned above, and you can do this codelab as a starting point.

Intercepting PouchDB communications with CouchDB backend

I am considering PouchDB & CouchDb as an alternative to Amazon Cognito Sync for a hybrid mobile app that will need data synced between devices and users. I have pouchdb working in a small sample app that syncs with a local couchdb.
I need to be able to intercept the communications back and forth between the pouchdb and couchdb in Java in order to do things in response to these sync events. Sort of like Amazon Cognito Sync's sync triggers. Also, I keep thinking much like Spring's AOP around.
Since the couchdb has a rest interface, I thought I could point the pouchdb to my application server which has a controller listening for any request with the db name as the base. When a request, from pouchdb comes in the Java Rest Controller can optionally do something, then forward the request to the real rest endpoint of the couchdb and get a response, then optionally do something again, then return the response to the pouchdb.
Does this seem like a feasible solution? I am currently working on trying to get this concept working. Has anyone else done anything like this? Any major pitfalls to this approach? Currently, I'm using Java 8 with Spring Boot & Jersey.
I think the architecture goes like this:
Data is empty everywhere.
Data changes, the device where the data changed pushes via a REST APIs.
Your server "master", send notification GCM or APN to devices.
In your notification listener, you check the type of notification and you sync the data.
If a new device connects to your "list of devices to sync" you send a push notification to sync the data.
Keep a list of connected devices.
The same ideas goes for every device/web browser. You have a local cache that you push to the "master" if it changes locally.
You will have many cases to deal with, and I don't think there are open source projects that offers the same patter as Cognito Sync.
Also think about scalability, devices don't have to pull your "master", the master sends notification to trigger devices to download the data.
You have to deal with diffs, regular checks, and so on ...
Good luck

Client Side Transactions in Azure App Service Offline Sync

Is it possible to leverage transaction on the client, when using azure app service offline sync?
It seems to me that you can pretty much only insert into the SQLite store a record at a time, but ideally i'd like to be able to commit multiple records in a transaction.
I'm using Xamarin with Android right now,but will be also supporting iOS.
Thanks
Matt
Unfortunately, on Windows, Xamarin, and Android you can only commit one record at a time on the local MobileServicesSQLiteStore. This is because changes need to be made one at a time using methods like SyncTable.UpdateAsync, which is how you mark a change as being tracked to send to the server.
On native iOS, the Mobile Services offline sync feature uses Core Data, which does support a form of transaction (https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreData/Articles/cdMemory.html). If you use these APIs, you still need to make calls to the Mobile Services SDK methods to track each individual change in the internal tracking tables.
Why do you need transactions on the client side? There might be a different way to achieve your goal.

Can I use PubNub for realtime data collection?

I'm interested in collecting realtime data periodically (say every 1 min.) through a mobile app on my server. Can I use services like PubNub or Pusher for it or are they only for communication in the other direction - like sending push notifications from a server?
If I can use, could you please explain how exactly the setup would work?
PubNub can provide bi-directional real-time datastreams on all devices, including mobile! Any phone (or server) can be a publisher, or a subscriber, or both.
You can choose your SDK of choice here http://www.pubnub.com/developers/ -- each client has docs for a simple hello world app.
If you need more assistance in getting setup with PubNub on mobile, just shoot us an email at support#pubnub.com and we will assist!

Receiving pushed messages from web service

I am working as part of a team using Android and WP7 to create apps that communicate with a server. So ideally we want a consistent approach to receiving the data from the server.
I currently am using HTTPWebRequest to form a SOAP message and send it to a Java-based web service to receive messages (Adding as a ServiceReference didn't work no matter what I tried) At the moment it's a simple case of receiving the full list of things and just recreate the list each time via DespatchTimer to do periodic calls. But of course periodic pollin is likely to be ratehr battery intensive so not the best apporach for my needs.
I now need to change the code so that changes are pushed rather than polled. The team is looking at XMPP to do this as Android libraries are readily available to do this but I am having trouble finding open source libraries to do this.
Microsoft Push seems available but this appears to require a Microsoft based server side environment to push unless I have misinterpreted this? Or even if push notifications are a sensible way to do this.
So what I would like to know is the approach to handling pushed messages in this scenario which i hope someone out there has had experience in
Thanks
Microsoft Push Notification System [MPNS] does not require a MSFT-based server backend. It simply relays the Push Notifications through carrier or other data channels to subscribing phones. You should be able to make HTTP POST requests to MPNS at the Windows Phone subscriber Channel URI & MPNS would deliver the Push Notifications for you. Your server side can be anything, as long as you able to make the HTTP requests.
A good starting point can be found here.
Hope this helps!

Resources