I'm facing a problem nowadays with my home router. I want to write a small application that will ensure the router will stop/switch off if no packets transmitted in last 30 minutes. Is there a way to do?
Precisely, I want to switch off my router/start it back through a Java program, desperately looking for some suggestion from some experienced coder.
Any help would be welcome.
Thanks
I guess the answer is that it depends on which router you have and what kind of interface it provides for controlling it.
My own router has no API that I know of which allows it to be directly accessed via a Java program (although yours might be different).
My router does have a web interface and can be accessed over HTTP. Conceivably by making the right post request I would be able to power off my router. I imagine you might find that yours is similar.
EDIT (added text)
To use the web interface you need to first find the IP of the webserver - probably 192.168.1.1 or 192.168.1.254 . Type this into your browser to get the control panel and find the button that turns off the router. Press this button with the network tab open in the developer tools (if you're not sure what this means use google) and capture the url it uses.
Now you have the IP and the request you can mimic this and send the same request directly using your Java code. Again to find out how look online. For example Sending HTTP POST Request In Java
END EDIT
The other problem you have is monitoring traffic to and from your router. You can do this a number of ways. Off the top of my head I would suggest using a raw socket to listen for all traffic and monitor everything that goes across the web interface of the device running your Java program. Alternatively you can use an existing solution like TCPDump which will do the same.
The question you have asked is very broad with a number of reasonable answers - it is also a kind of big question - so I have tried to provide some reasonable thoughts to get you started rather than actually write the code for you.
Hope this helps.
Related
I want to communicate with my DFM-562IS D-Link modem (that is connected to my computer's mainboard via a PCI slot) using Java. The goal is listening for incoming calls and receive a code that the user enters on the other-side after connection (by his/her phone's keypad).
So far my searching on the Internet didn't give me anything useful and I found some closed old threads only (Here and here for example).
I just want to know if is it possible? and If so, give me a guildline please.
I really appreciate for shedding a light on this issue.
Thanks in advance
Update:
If the goal is achievable with GSM modems, please provide the related solutions for the issue in your answer also.
I'm sure it's possible, but I doubt it's very popular these days!
I don't know much about modems, but presumably if you can't find a higher-level library then you could communicate with them via the serial port using the Java Communications API or RxTx.
To see an exmaple of communication with a GSM modem, have a look at SMSLib.
If you are looking to support IVR, then you may not be able to find Java support for it. Software like FreeSwitch may help.
Now, I have some problems here:
I looked several times in Google and so on, but I can't find an "easy" way to get this done. And currently having a migraine... not helping me... though
I have a java eclipse program (Swing application to be a "controller" for production-machines).
I need to design an Android app, which needs to take data from the eclipse program in a wireless network (and also send them back).
Just found solutions like JPARSON or setting up a real server, but that is way too complicated... i donĀ“t need?! (or want :D ) to set up a whole website with php or something...
Can someone of you help me out with a better solution? It doesn't need to be code-specific, I just want to exchange like 10 strings for these machines.
If you want to exchange data you need a communication medium. The easiest way to do this is via TCP/IP protocol suite. If you decide on having a Server-Client architecture, your serwer has to listen for what phones have to say. He can do this by listening on specified port and you would have to handle "protocol", or you can use somewhat easier approach which is to write php script, or Java Servlet. PHP script is easier becaouse there is like a gazzilion php hosting providers and it's cheap. If you would like to write your own serwer, you wold need some sort of Virtual Private Server, and deploy your app there. Plus it would be helpfull if you explained a little more your environment and what you are trying to achive.
There's built in httpserver http://docs.oracle.com/javase/6/docs/jre/api/net/httpserver/spec/index.html so you can easily implement a simple webservice in standalone java. Then just use URLConnection from android to post/get data, probably in json or your own format.
I want to make a multiplayer Android game and am an absolute novice at anything and everything networking. I have some knowledge of socket programming in C and Java, however from what I understand, it is not that simple when communicating from an Android device to a remote server. Basically, I am just unsure of how to go about setting up server-side components of this project. I've been told to look into frameworks, but am not really sure exactly how they would be used in my particular case.
Here is a breakdown of how my application works and how I want it to communicate to the server. The client application will send a request to the server whenever a user wants to login, create game, make a move, check statistics, etc. The server will update or retrieve information from a database(somehow) and send it to the client. If the player is to make a move, the server is responsible for doing all calculations, storing the gamestate, and pushing the updated game to both players.
I was hoping somebody could shed some light on how I would go about starting this. Any information would be greatly appreciated. Thanks
Essentially you want to set up a Socket Server program listening on your server for connections from the client. You can achieve this through any number of ways, but it seems like you are going to want to tap into a database (such as MySQL) running server side in order to handle authentication of users logging in, etc. Since you say you have familiarity with Java already, and Android is Java based, I would suggest you go with Java for the server application. A few things to look into to get started would be:
Socket Programming in Java:
http://docs.oracle.com/javase/tutorial/networking/sockets/index.html
Chat Client/Server Examples in Java here:
http://pirate.shu.edu/~wachsmut/Teaching/CSAS2214/Virtual/Lectures/chat-client-server.html
Also look into Java JDBC tutorials on Oracle's website (for interfacing Java with a MySQL server), and you will likely find that Android AsyncTask class will come in handy when you implement your Android client. It might be better to start with a pure Java client to get the server aspect working first and then move to an Android-based client. Once you establish some code you can make more refined posts here and gather more specific answers. Hope that helps and good luck.
I need to add a functionality to my java-based web application that will allow users to click on a link and the application will automatically call the user and another party and connect them in a phone call.
Does anybody know what would this entail?
Thanks
It can be done with Twilio, and their new, easy Conferencing API. Trust me, it's really really simple. Another option might be CloudVox, but I haven't (formally) tried their service yet.
The World-Wide Web Consortium has an integrated set of speech interaction standards that you'll find interesting. There's a markup language called VoiceXML that is analogous to HTML in that web applications generate it. It differs from HTML in that it's specialized for temporally-based speech interactions instead of visual interactions. So instead of looking at a screen you listen to audio prompts and computer-generated speech. Instead of typing and mousing, you speak back and what you say is processed by a speech recognizer or recorded.
There are many companies using VoiceXML to automate voice response systems, and they handle billions of calls per year. You've probably talked to them many times without realizing it. One of the best companies in this space is Voxeo, and they have a developer site at http://evolution.voxeo.com/ that you can play with. Evolution lets you call your web application over an ordinary phone (or Skype). You actually talk to a VoiceXML-based web browser which will fetch a VoiceXML page from your Java application server, "play" it to you, listen to what you say, and then report that back to your app via a form submission, get the next page to render to you, etc.
Another related standard is CCXML, or Call Control XML. You use this to create teleconferences that may or may not include a voice response application.
So it sounds like in your case you want your standard web application to talk to a CCXML server and ask it establish call legs to the web user and to a customer service line. I know that Voxeo Evolution offers CCXML as well.
There are other good companies in this space too. One that comes to mind is TellMe, which was bought by Microsoft a year or two ago. These two companies (and others) offer professional services too.
So I wanted to write this up as an answer to the comment above. The Skype API provides a number of options for telephony in COM, Java and Python:
Skype4Java - https://developer.skype.com/wiki/Java_API
Skype4Py - https://developer.skype.com/wiki/Skype4Py
Skype4COM - https://developer.skype.com/Docs/Skype4COM
They provide a communication and command protocol layer for working with Skype, more info on the API here:
https://developer.skype.com/Docs/ApiDoc/Overview_of_the_Skype_API
It's kind of different for every platform, the Linux version is based on DBus or X11.
Try FreeSWITCH. I have done this before. Its pretty straight forward. Can be a bit hairy when you need to log call accounting and all those stuff. I hopefully would be able to provide you some guidelines and code samples, let me get home first. Cheers.
The good thing in using FreeSWITCH, you will be able to handle multiple calls, and quite a number of. You might need that in future.
Note: You have to use some kind of VoIP provider in order to do that. I was using Gizmo5 that time and it was pretty good.
Sorry buddy, lost the servlet code somewhere. But no worries it was a simple servlet. Fortunately, I had added my example Java code for XML-RPC, into the FreeSWITCH wiki, and actually that was the code my servlet was invoking down the road. Below is the snippet.
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
XmlRpcClient client = new XmlRpcClient();
try {
config.setServerURL(new URL("http://localhost:8080/RPC2"));
config.setBasicUserName("freeswitch");
config.setBasicPassword("works");
client.setConfig(config);
// For external phone calls using VoIP. We will use something like below.
// new Object[]{"originate", "sofia/gateway/gizmo1/6098989898 &bridge(sofia/gateway/gizmo9/0116054545454)"}
// gizmo1, and gizmo9 are the accounts configured under freeswitch gateway configuration.
client.execute("freeswitch.api", new Object[]{"originate", "sofia/internal/1001 &park()"});
} catch (Exception ex) {
ex.printStackTrace();
}
Moreover, you need to configure few things prior doing this. You need to set up the gateway using your VoIP provider settings.
For FreeSWITCH related help, take a look at this SO Thread.
I know of 2 API providers that does what you need:
1) twilio - can connect to 2 or more parties using TwiML (their markup). example
2) Hoiio - very easy to use with 1 line of RESTful api call. example
how can I let an SWF file to retrieve values immediately from Java application that does live calculations (Speed is a necessity).
question in other form : how can I
give my website browser immediate data
- that are bean calculated now - as fast as i
can ?
I'm going to assume the calculations are being done in a Java applet in the same browser where the flash is running.
You can call Javascript from within the applet using the following code. This code could then update the values in the flash animation.
import netscape.javascript.JSObject;
JSObject win = JSObject.getWindow(applet);
win.eval("window.alert('Hello from Java')");
If my assumption is incorrect, then where is the Java application running? On the client or server?
If it's on the server then you need Flash remoting. I believe there are a few different Flash remoting techniques. Try searching for java flash remoting. You can make it call the server every 2 seconds or so to get the latest data.
If it's running on the client I doubt you can connect to it from Flash because of security. A signed Java applet could connect anywhere it wants to. You could retrieve the data using it, then push it into Flash using the method described above. Would be a crazy hack though. Can you do the same thing with Flex? (I've never used Flex before).
If the speed is crucial, you would probably want to do it via some kind of socket connection. Usually signed applet or a WebStart Java application is able to open a listening socket. Flash application then would be able to connect to this socket and as a result you will have very fast bidirectional communication.
There are some caveats however.
You should bear in mind that user might get suspicious about weird socket activity on his machine, or it would be just blocked by a firewall - so you'll need to warn user.
In order to be able to connect from Flash to Java, you must dispatch crossdomain policy file from the listening socket (or any other below 1024 - see documentation for details; keywords: crossdomain, policy-file-request, loadPolicyFile). Also your Flash application might need to request such file manually from the Java application.
Couple of useful links on how to get certificate for your Java application: how to get free code signing certificate (Russian), similar but less detailed description in English.
However, if you are able (read: the speed is sufficient) to use Java Applet <-> JavaScript <-> Flash combination I'd advice to take advantage of it.