I was wondering if anyone is aware of tutorial/resource to learn how to connect to a websocket server using a JAVA application, instead of html5. I've been searching and can't find anything as they all give a server websocket example in java but client side in html5.
I know you can do http GET/POST in java, so I was wondering what step I would need to enable websockets via java based console app, vs html5.
try{
connection = (HttpURLConnection)serverAddress.openConnection();
conection.setRequestMethod("GET");
connection.setDoOutput(true);
connection.setReadTimeout(1000);
connection.connect();
reader = new BufferedReader(new InputStreamReader(connection.getInputStreamReader()));
sb = new StringBuilder();
while((line=reader.readLine())!=null){
sb.append("Recieved: "+line+"\n");
}
}catch(Exception e){e.printStackTrace();
}finally{
connection.disconnect();
reader = null;
sb=null;
connection=null;
}
how can I turn this method here into a websocket connection?