2

The SignalR with the Java library is a great choice for realtime communication. Though it is possible to subscribe to hub on the onCreate and to close it. But what happens when the application is killed ( manually or automatically) or even the activity is dead. One solution is to use a service - that is basicly same as creating a GCM, OR the other one is to make juggling with push notifications, and send them also and than synchronize what is already sent to the user(bad thing)

Suggestions ?

Dan Kuida
  • 1,017
  • 10
  • 18
  • IMHO, you can use a service as in your question. Pls see my answer at the following http://stackoverflow.com/questions/32573823/how-to-use-signalr-in-android/32574829?s=0|5.7792#32574829 if you have not read it before. – BNK Nov 10 '15 at 00:02
  • Your answer is very detailed and good, but still it does not answer mine. Service can be killed, so in order to trigger it back the only way I see is to send a push notification.So how you suggest to solve that ? – Dan Kuida Nov 10 '15 at 10:01
  • If you make it a sticky service (return START_STICKY from onStartCommand), then the service will be recreated after kill with a null intent https://developer.android.com/reference/android/app/Service.html#START_STICKY – Abu Ruqaiyah Sep 01 '16 at 16:10
  • @DanKuida have you found any solution for this – M.Yogeshwaran Nov 02 '16 at 09:15
  • @M.Yogeshwaran - yes - not to use signlar, sockets and signalR are horrible on mobile, the best solution would be to use commet - as PubNub have implemeented it - but that is quite a lot for a standalone application, so my solution was to implement a request queue where I trigger all the calls based on type of calls in the queue – Dan Kuida Nov 02 '16 at 11:44
  • so you are telling that signalR is bad for mobile – M.Yogeshwaran Nov 02 '16 at 12:00
  • yes thats exatcly what I am telling @M.Yogeshwaran – Dan Kuida Nov 02 '16 at 21:40
  • then whats your implementation can you please share some ideas regarding this – M.Yogeshwaran Nov 03 '16 at 05:25
  • The best implementation would be making queries with push notifications/ plus in chat polling in case push fails, buit more advanced would be - message que with retry andd confirmation of delivery, on top of that possible to extend to Jabber/xmpp. a bit mre advanced for large scale would be backend storage with riak and delivery using commet like FB doing that, of course backed with some push for bg response - all depends on the need – Dan Kuida Nov 05 '16 at 17:46

1 Answers1

1

BNKs example is good, and to recreate service after kill, just use START_STICKY return value in onStartCommand, as mentioned here https://stackoverflow.com/a/20557120

Community
  • 1
  • 1
Abu Ruqaiyah
  • 1,516
  • 1
  • 12
  • 20