I'm building a java stand alone application. This application is installed on one pc. There is another java stand alone program that it is installed in another pc to another net.
Now I want to send a notification with these program. For example the program 1, send message "start update", and the program 2 read this message and can execute an activity.
Now how can I implemented this push notification.
I have also a php server, I don't know if this server is necessary.
It is a little strange question... you can use lot of technologies e.g. Rest, JMS, but also ugh you can send UDP packets or use a pipe on file system. It depends to what you have to send, for which purpose, with which security level.
Related
I want to make a TeamSpeak 3 Musicbot in Java. But I don't find any Protocol from Teamspeak for the Voice transmission. And after searching for a Client API, for Java, I didn't find anything. Only for a ServerQuery but that doesn't help me I think.
I only want the Client to connect to the Server and then plays a Song, though that wouldn't be that hard!
Maybe you Guys can help me?
Teamspeak does not have an official client-api. You can only use the Query-API and create plugins. As the Query-API does not support any voice-communication, that's not the way you should go. The (most) official way of creating a Teamspeak3 MusicBot would be to run a client on your server which has a plugin installed which allows you to play music (more or less a soundboard). Sinusbot is exactly built this way.
Another "unofficial" option would be to make use of unofficial reverses of the teamspeak-protocol and built you own client from these. If you want more information about this, this repository might help you (and look for other projects the creator pushed, they might help you too).
I'm not quite sure if this helps, but have been developing a TeamSpeak 3 music bot using Kotlin, which is compatible with Java as it runs on the JVM (Java Virtual Machine)
The way it works is that it first launches the TeamSpeak client and connects to the desired server and channel, then it starts monitoring the chat log -> the bot can be controlled by entering commands into the chat.
The bot uses the TeamSpeak ClientQuery via Netcat to send messages to the chat.
It is completely client-side so you don't need to be server admin to get it working.
The bot currently supports Spotify, YouTube, and SoundCloud.
You can check it out at https://gitlab.com/Bettehem/ts3-musicbot
I have application Android to control computer (restart,shutdown,...) by connecting Android application with a Windows application (vb.net) through the Web Service
I do not know where to start and how to contact Anyone who has any idea on the subject ?
Since this is a broad question and you asked for ideas let me pour some thoughts.
Where to start? Define a protocol for the web service that both parties understand. For example define an URI that the android client can push messages to (with PUT or POST) and the vb.net client can poll for updates (with GET). Since we use one URI here the payload sent to the URI must define what to do. The android client could for example post the message '{command:restart}" then the vb.net client should know that he has to restart the machine if the message is received.
There are a few caveats here though. First the vb.net client needs to poll the URI to get the command. So between sending the command and executing it there is some delay. Even better, right now you don't even know if the command was executed or not. Also since there is no authentication everybody can issue commands to the web service. Sounds like tons of fun. For other parties at least. Lastly you need to clear the command from the URI if it was executed or updated. Else the machine would, in this example, go into a restart loop.
So the first problem may be solved with and extra URI where the android client can poll for some king of system state that the vb.net client provides. For example the vb.net client may send the message '{state:restarting}' to the URI before restarting. Of course the vb.net client needs to update that URI every time some event happens. The security issue? Security is hard. You may want to create a certificate and sign the requests sent so the server with it. Then the server can check if it was really you who sent this request. Or somebody that has your cert, replayed the request or found some way of breaking the whole stuff. So you additionally might want to use TLS with some king of certificate pinning. You might already know this but I'm going to repeat it anyway: do not send credentials over an insecure network. Also base64 (used in basic authentication) is not some kind of encryption. The last problem may be solved with a nonce that can be included in the command. Or the vb.net client clears the command from the URI (with DELETE) when it received the command. It should update the status URI though so that the android client does not send the request again.
Or you drop the whole web service stuff use technologies like Web Sockets. Then the android client can send a command to the socket. The server receives to command and sends it to the vb.net socket. When the command is received by the vb.net socket it sends out some kind of delivery receipt to the server and executes the command. The server receives the receipt and sends a confirmation the the android client so that it known that the command is going to be executed.
As you see there is a lot do do when implementing such a solution so let me summarize:
define you use cases. What operations must the system support and how are the participating parties involved in any case.
find corner cases for each use case. For example the authentication problem that needs to be solved.
do some research on technologies that support your idea at the best possible way. Maybe a web service is not the best solution? What is a web service anyway? (Seems to be some king of buzzword anyone uses). Maybe Web Sockets, XML RPC or even SOAP are better candidates?
define a protocol for the components
implement it
One last note. I know this is a rather long answer? that might spawn a lot of questions in the readers head. But, do not get discouraged! You don't have to do anything that I wrote here. Well except the security thing maybe.
I currently am developing a semi-simple chat app. I want the user to be able to communicate with one other person in a private chat. Just plain text will be sent. Currently my system calls php scripts from a webpage, passes in parameters and then parses the data returned. I have it so that the client sends the message, which calls a send message script on my webserver, the script then makes a message file on the webserver and then returns a success or failure back to the client. Then for the client to view this message, it would have to call a script that checks the server for a message file with a message for him. If it finds one, it sends the message back, if not, it sends a response about not having messages.
This technique works perfectly besides the fact that the client either would have to manually refresh to check to see if he had messages, or a background thread would have to refresh every few seconds. That would be fine, however that would use data if the user was on a mobile network. Not to mention the kind of resources a background loop would pull if it was refreshing at a speed that would be convenient.
So, I decided on a second idea, this would be a server programmed in Java, which would communicate over sockets. The user would send the message as a packet over the socket and the server would check to see who it was meant to go to. If the person is online, it passes the message along to that user. However this method requires a constant connection between the client and the server and that is unreliable because what if the user is in the car and data cuts out. Or some other situation where the connection gets severed. Then it would throw errors and have to reconnect.
Anyhow, my question is which technique is better. Or are they both terrible? If so, what is the correct way of doing this? Thanks in advance.
AngularJs and Ajax will be the perfect solution for you , try to learn
for actually real time messaging Use AngularJs
If the amount of data is very less ..say 20-25 messages per day...you can REST APIs on your server to transfer actual text messages and Google Cloud messaging for pushing notifications..Recently I followed this approach to develop private chat for one of my friend.
I am doing a lot of long lasting computation stuff in java and want to stay informed.
Is there any standard method ( library etc. ) to send push notifications from a desktop java program to my Android device?
When there is no , could someone provide me with some starting ideas how to write this on my own?
The "3rd-party application server" mentioned in https://developer.android.com/google/gcm/server.html can also be a desktop pc running a simple java program.
You will need to setup some IDs, an app that receives push messages, a way to display the phone registration ID so you can enter it in the desktop app.
But the rest is basically as simple as adding the gcm server jar to a desktop app (I'd use this version here: https://github.com/kurthuwig/gcm/commit/d37f4d1c37ed8deaf1a161ca7b881c1d843f80df ) and then calling 3 methods or so.
Like what zapl suggested I would say GCM is a good choice. Also, all benefits aside, if you're into messaging you can have a go at AMQP, specially the RabbitMQ implementation. You can run the RabbitMQ server on your desktop and push your messages out to all listening devices.
when building a server, one sometimes performs asynchronous tasks from client to server (which responds to client in asynchronous time),
or the server needs to send the client a message
now if the client is listening at all times (meaning polling) it takes a lot of resources which is problematic
here is where I assume the operating system steps in and assumes the role of polling for the appropriate port, and letting the application know using the appropriate event (the application subscribes using the OS API)
am I right in my assumptions?
how do I subscribe to a port using the OS's API? (lets say android for the sake of argument)
how is a message from server to client work exactly?
and how does the server know the client's IP at all times?
I have seen many questions in the subject, but wasn't able to figure out the big picture
Edit:
I am using GCM in android, but have seen other apps that does not use it and still manage to do it right, also it's a more general question as to what is the right approach in java VS. any operating system it uses (ubnutu, windows, android, etc.)
Totally right - polling is typically a waste of resources. Until recently, many apps would either keep a socket open and poll every few minutes to keep it alive, or make periodic HTTP calls to a server.
Nowadays, Google Cloud Messaging is used by most apps to push data instead of constantly polling. As you correctly guessed, this is implemented by maintaining a persistent connection with Google's servers. The advantage of this is that it's very efficient for battery life, and that all apps can use this one resource to send push notifications, instead of each app having to poll a different server or create its own persistent connection.
The idea is that you send requests to GCM from your server (this can be in response to user activity, etc), which sends it to all of the client's devices. You can either send a message with a small payload (up to 4kb) or a "send-to-sync" message, which tells an app to contact the server (e.g. to sync new data from the server after user changes).
here is where I assume the operating system steps in and assumes the role of polling for the appropriate port, and letting the application know using the appropriate event (the application subscribes using the OS API)
GCM pushes messages to clients, so there isn't active waiting like you'd see in a simple polling system.
how is a message from server to client work exactly? and how does the server know the client's IP at all times?
There's no need for servers to know the client IP, as any online android device will typically maintain a connection with GCM. Targeting specific users is done via User Notifications.
(Oh, and I realize that your question is more general than just Android, which I have more experience in, but iOS has a similar system in place. Some developers I've met like to use Parse for managing push notifications).