I'm trying to create an application event (java) that would raise as soon as the machine gets connected to gmail onto the login page (https://www.google.com/accounts/), so I'm trying to build a Socket that would listen to this particular httprequest.
but I can only create a ServerSocket that listens to a port, to a specific ip adress (gmail login page can have so many different ips), but not to a host...
anyone got an idea ?
thank you !
This should help you get started:
http://gforgeek.blogspot.com/2005/04/simple-packet-sniffer-using-java.html
EDIT:
I just checked and I think you're going to have a really hard time accomplishing this because gmail runs on HTTPS so even once you get the packet sniffer running you're going to have to decrypt all SSL communications. I'm not even sure that's possible.
Best bet is inside the browser like Google's Mail Checker extension for Chrome. Modify the extension to forward notifications to a localhost HTTP service which your Java application is hosting.
Related
is there any way to block / close multiple websocket connection from the same browser tab for a client?
I'm creating simple card game using javax.websocket in a backend and pure js in frontend. In the app I'm not going to use any login and password authentication system.
I'm looking for some method where I can close second connection if the client is already connected.
Thanks!
This would work if there was some kind of unique identifier for each player (ie. authorization token).
Otherwise you could check their IPs, whether they are already connected and disconnect them if so. This can be easily bypassed, and there arise issues when there's multiple clients from one router.
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 want to have a Java-Application that is behind a firewall (maybe even connected over a 3G modem) and I have a google app-engine application.
How can the gae app push data to the clients?
I found some ways that look promising, but I'm not sure what will really work.
Sockets will not work, because I cannot connect through the firewall/3G barrier
the channel API only works with JS clients
XMPP looks very promising - the client would report it's presence and the server could push chat-messages to the client and also the client could reply that way.
But what about user-accounts? i.e. could I use a single XMPP-account for all users (and let the client send a unique ID to identify the user) - or is a unique XMPP account for every device (which runs the java-aplication behind the firewall) required?
are there any other options or are there some XMPP gotcha's you know about?
I have an android application which sends information to a server in particular it sends some stats to check the normal use that users do with the app. For example if they click a button to see a specific page a stat is sent to the server specifying a series of informations like the model of the phone, the page requested, the version of android ecc ecc. These informations are later visible using splunk http://www.splunk.com/. Now my problem is, for each event sent by my app, I should be able to say if the event was correclty sent to the server or not. My idea is to develop a proxy that can intercept the requests made by my app to the server and listen the response, like Charles proxy does. The problem is I don't know where to start. Anyone can suggest me how could accomplish this task? Thanks
Well I think you could add code to your application so that, when you send your data, you get the HTTP reply and check if code is 200 (Which stand for OK responde from server).
If so you know that your request went fine, if not(different reply code) you treat it as an error.
You will have to check if your server is responding properly, for an error and an OK message.
See also HTTP STATUS CODES
A good idea would be to use the Proxy Design Pattern for your extra code.
I am interested to make a chatbot. My script is currently working fine with imified.com bot. however imified is down almost everday. so i am looking for my own solution.
during my findings, I have found (through this site) openfire and I have configured it and it is working fine even with gmails users.
but i am still not getting what I need.
I need to request a URL (with the chat scripts and some other user data something like imified provides) when each gmail or other external users send me a message. let me explain.
my openfire is hosted and working for mybot.com and my id is: autobot#mybot.com.
now a gmail user say client#gmail.com added me in his gtalk/piding and we can communicate each other. he can send me message and I can reply.
but I need a robot instead of me. when client#gmail.com (and any other user) sends me a message, I need to request a URL so that i can dynamically generate response based on the message he/she sent.
in which way I should go for achieving this? Is there any way to customize openfire to do so?
or should I make a php/python (i need to learn python though) script that will listen to xmpp ports and generate responses? if so, any helpful scripts that may guide me?
bunch of thanks for reading it and thanks in advance for providing any response.
The OpenFire understand XMPP, what you need is XMPP library/API (like XMPP4R if you are Rubyist). Using it your app will login to OpenFire (by sending gmail/yahoo credentials) and others will see you as online. But when they will reply to you, you will be notified in your application. Where you can receive the message, process it, and send response (by writing a required program/logic).
We have done it in our SMS Chat application with Gmail/Yahoo messenger friends/contacts.
Openfire is XMPP-server. It's route messages between XMPP-clients.
You need XMPP-client which connects to server and process messages from other clients.
For example you can look here. That page contains two simple bots.
you can also use xmpp js lib 'strophe'
https://github.com/metajack/strophejs
and the xmpp python lib
https://github.com/fritzy/SleekXMPP
and the xmpp php lib
https://github.com/alexmace/Xmpp
have a try and good luck
You can try out our XMPP chat bot, it has been tested with openfire :
http://github.com/gbin/err
It is super easy to setup, and making a minimal hello world plugin is quite easy, no need to manipulate XMPP :
see https://gist.github.com/2902497