|
@@ -5,14 +5,14 @@ import java.io.Reader;
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
-import org.codehaus.jettison.json.JSONException;
|
|
|
-import org.codehaus.jettison.json.JSONObject;
|
|
|
+
|
|
|
import org.eclipse.jetty.websocket.api.Session;
|
|
|
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
|
|
|
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
|
|
|
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketError;
|
|
|
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
|
|
|
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
|
|
|
+import org.json.JSONObject;
|
|
|
import org.robert.printer.common.PrintersDiscovery;
|
|
|
|
|
|
@WebSocket
|
|
@@ -60,7 +60,7 @@ public class PrintersSocketHandler {
|
|
|
}
|
|
|
|
|
|
@OnWebSocketMessage
|
|
|
- public void onMessage(Session session, Reader reader) throws IOException, JSONException {
|
|
|
+ public void onMessage(Session session, Reader reader) throws IOException {
|
|
|
String message = IOUtils.toString(reader);
|
|
|
|
|
|
if (message == null || message.isEmpty()) {
|
|
@@ -79,10 +79,9 @@ public class PrintersSocketHandler {
|
|
|
* @throws JSONException
|
|
|
*
|
|
|
*/
|
|
|
- private void processMessage(Session session, JSONObject json, SocketConnection connection) throws JSONException {
|
|
|
+ private void processMessage(Session session, JSONObject json, SocketConnection connection) {
|
|
|
String action = json.optString("action");
|
|
|
|
|
|
-
|
|
|
if (action.equals("list")) {
|
|
|
JSONObject printerNames = PrintersDiscovery.getPrinterNames();
|
|
|
this.send(session, printerNames);
|