ASP.NET MVC background work - Best practice - android

I'm developing an ASP.NET MVC 5 application which is supposed to receive and send messages to Android smartphones. The way I have currently implemented it is by using a message broker (RabbitMQ in this case) and let that broker handle the communications between the backend and the smartphones.
In the ASP.NET code I am creating a thread which is run at the beginning of the application in global.asax (I have seen some people who recommends this, maybe I am doing it wrong...). This thread is in charge of listening to the messages that the broker receives and then process them.
My question is: is this a good practice in terms of handling external messages in an ASP.NET application? This is the first time I program this kind of applications and I don't know if I am doing the things right. Does anybody know another ways to receive messages from an external device in ASP.NET? Again, keep in mind I'm very new to ASP.NET, maybe I am asking something stupid but I just need some information about this.
Thanks!

In case someone has a similar question I will answer how I made it work. At the end I used HangFire (http://hangfire.io/), it is quite easy to configure, just need to add this code below in Startup.Auth file:
GlobalConfiguration.Configuration.UseSqlServerStorage("db_name");
app.UseHangfireServer();
app.UseHangfireDashboard();
And the following code to start the background task:
var storage = new SqlServerStorage("db_name");
var client = new BackgroundJobClient(storage);
client.Enqueue(() => rabbitInstance.MethodXYZ());
I hope this solution is helpful for more people.

Related

Android Chat with own resources / Pull data live from server

I started with a application where you can chat.
Now im in the position to start with the chat.
The problem I'm facing is that I don't want to use
resources from "outside". With outside I mean:
Firebase, Socket.io and so on.
I do simply rent a webspace. And I'm asking you now,
how is it possible to realize an live chat without
using extern services like firebase.
Is it possible with only using an Webspace?
What is required to make an live chat?
And there comes the second question:
How do I realize to stay connected to a server to check if there is a new message without using much battery or network ressources?
I'm not asking without hardly trying by my self.
Two days ago I started with the research of possibility, but I didn't found anything which would work I guess.
Thanks folks...
You need to connect to the Web Server using a Socket and keep that connection open to receive new messages with little delay (see for example http://srchea.com/build-a-real-time-application-using-html5-websockets) This keeps the phone active and uses much battery.
The very purpose of Firebase is to bundle this work for all services which need this type of communication (E-Mail, Push messages of newspapers, Chats) such that the phone only has to query one server. Therefore, I see no way for you to find another solution which uses little battery.

Don't know where to start in learning about sockets and connecting mobile devices?

So I want to be able to connect my android device to my iPhone, and use that connection as a bridge to get the iMessage service "on" my android. Now these people here have already done just that, unfortunately it doesn't look like they're going to be making it into a messenger application like I want to.
So that is just my end goal, and because I have just started to become proficient with java, that goal is a long ways a way, which is why I was hoping some one could give an explanation as to how they manage to make their remote messages web application work, so I can 'get the ball rolling'.
So if someone could dumb it down and explain what is going on from the time I run the remote messages web application to the time I send a text message I would be very appreciative. I hope the this isn't too vague of a question. I am just trying to get an idea of what I need to start learning.
Thank You

how to use websokets in phonegap application for notify user?

I need to write phonegap(ios and android) app that in background listen websockets connection and notify user.
Is any plugin for that, exist? Or any other way to do it ?
I'm pretty sure that the network stack (and therefore WebSocket connectivity) is interrupted when an application goes into the background. I think all you really have time to do is register an APNS / GCM handler when the OS tells you to suspend your application.
You might want to ask this question on the Kaazing Website (there are a few folks there who know this stuff) to confirm this.
This plugin https://github.com/mkuklis/phonegap-websocket adds basic web sockets functionality to phone gap on android. In addition, you can use also socket.io if you want a more elaborate javascript API that what vanilla web sockets provide.

server client android application vs client only

Hi i'm relatively new to android programming and am trying to do the following. I want to create a messaging system in which immediate response is not (at least for now necessary). I am completely new to networking / socket programming but have followed this:
http://www.tutorialspoint.com/python/python_networking.htm
and have kinda got my head around it.
I have the following question with regards to best practice.
What are the advantages/disadvantages of method A and B.
Method A:
Have a server and client running on the app.
Method B:
Have a client running on the app and pinging the server every minute for data.
Apart from the obvious that Method B doesn't allow real time which is better suggested? Does a server application take too much memory / CPU / battery etc? I know a lot of IM apps exist, how do they work?
Thank you in advance
Why not use push notifications?
http://developer.android.com/guide/google/gcm/index.html
I would recommend Google Cloud Messaging but last time I checked you needed a dedicated server to install it. Or Am i wrong? I only had a shared server so:
method A: the difficult part, considering its a mobile device, would be to keep the connection alive when your phone changes IP (another wifi network for example) and
method B: you could make small simple messages in order to check if there is something new and update in that case. My app sent around 500 bytes every 30 seconds and I didnt have any battery related problems. It also didnt slow the phone down.

How to design a remote controller for an android application?

I've written an android application, and I'd like to make it controllable to other machines by sending HTTP request to the device that run my application. I've written a tiny HTTP server and made it start when my application is started. I know I could translate HTTP requests and send messages to various activities to perform UI operations, that need to add listener to all my activities. But in order to make the remote controller code reusable, I hope separate remote controller code from existing application code and thus I need to find a way to make as less as change to the application code to make it be remote controllable.
Could anyone share your ideas?
I dont get what you are asking tbh but in one of application that my friend create, he just implement a mouse pointer which works from any android phone. With that application he can manage to use the android tv.
When he was implementing that app, he took advantage of socket programming and send messages from remote controller, in that situation a phone, to other device and fetch the data in there. In my opinion if you follow such a manner you just dont need to apply so many changes in your other applications. It is all communication in the end.

Categories

Resources