org.eclipse.jetty.websocket.WebSocket.Connection Java Examples
The following examples show how to use
org.eclipse.jetty.websocket.WebSocket.Connection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SendingTask.java From IoTgo_Android_App with MIT License | 6 votes |
@Override public void execute(JSONArray args, CallbackContext ctx) { try { int id = args.getInt(0); String data = args.getString(1); boolean binaryString = args.getBoolean(2); Connection conn = _map.get(id); if (conn != null) { if (binaryString) { byte[] binary = Base64.decode(data, Base64.NO_WRAP); conn.sendMessage(binary, 0, binary.length); } else { conn.sendMessage(data); } } } catch (Exception e) { ctx.error("send"); } }
Example #2
Source File: DisconnectionTask.java From IoTgo_Android_App with MIT License | 6 votes |
@Override public void execute(JSONArray args, CallbackContext ctx) { try { int id = args.getInt(0); int code = args.getInt(1); String reason = args.getString(2); Connection conn = _map.get(id); if (conn != null) { if (code > 0) { conn.close(code, reason); } else { conn.close(); } } } catch (Exception e) { ctx.error("close"); } }
Example #3
Source File: SendingTask.java From IoTgo_Android_App with MIT License | 6 votes |
@Override public void execute(JSONArray args, CallbackContext ctx) { try { int id = args.getInt(0); String data = args.getString(1); boolean binaryString = args.getBoolean(2); Connection conn = _map.get(id); if (conn != null) { if (binaryString) { byte[] binary = Base64.decode(data, Base64.NO_WRAP); conn.sendMessage(binary, 0, binary.length); } else { conn.sendMessage(data); } } } catch (Exception e) { ctx.error("send"); } }
Example #4
Source File: DisconnectionTask.java From IoTgo_Android_App with MIT License | 6 votes |
@Override public void execute(JSONArray args, CallbackContext ctx) { try { int id = args.getInt(0); int code = args.getInt(1); String reason = args.getString(2); Connection conn = _map.get(id); if (conn != null) { if (code > 0) { conn.close(code, reason); } else { conn.close(); } } } catch (Exception e) { ctx.error("close"); } }
Example #5
Source File: DisconnectionTask.java From WebSocket-for-Android with Apache License 2.0 | 6 votes |
@Override public void execute(String rawArgs, CallbackContext ctx) { try { JSONArray args = new JSONArray(rawArgs); int id = Integer.parseInt(args.getString(0), 16); int code = args.getInt(1); String reason = args.getString(2); Connection conn = _map.get(id); if (conn != null) { if (code > 0) { conn.close(code, reason); } else { conn.close(); } } } catch (Exception e) { if (!ctx.isFinished()) { PluginResult result = new PluginResult(Status.ERROR); result.setKeepCallback(true); ctx.sendPluginResult(result); } } }
Example #6
Source File: SendingTask.java From WebSocket-for-Android with Apache License 2.0 | 6 votes |
@Override public void execute(String rawArgs, CallbackContext ctx) { try { String args = new JSONArray(rawArgs).getString(0); Connection conn = _map.get(Integer.parseInt(args.substring(0, 8), 16)); if (conn != null) { if (args.charAt(8) == '1') { byte[] binary = Base64.decode(args.substring(args.indexOf(',') + 1), Base64.NO_WRAP); conn.sendMessage(binary, 0, binary.length); } else { conn.sendMessage(args.substring(9)); } } else { } } catch (Exception e) { if (!ctx.isFinished()) { PluginResult result = new PluginResult(Status.ERROR); result.setKeepCallback(true); ctx.sendPluginResult(result); } } }
Example #7
Source File: WebSocket.java From IoTgo_Android_App with MIT License | 5 votes |
@Override public void initialize(CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView); _factory = new WebSocketClientFactory(); _conn = new SparseArray<Connection>(); _create = new ConnectionTask(_factory, _conn); _send = new SendingTask(_conn); _close = new DisconnectionTask(_conn); try { start(); } catch (Exception e) { } }
Example #8
Source File: ConnectionTask.java From WebSocket-for-Android with Apache License 2.0 | 5 votes |
/** * Constructor * * @param factory * @param map */ public ConnectionTask(WebSocketClientFactory factory, SparseArray<Connection> map) { _factory = factory; _map = map; if (!_factory.isRunning()) { try { _factory.start(); } catch (Exception e) { } } }
Example #9
Source File: WebSocket.java From IoTgo_Android_App with MIT License | 5 votes |
@Override public void initialize(CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView); _factory = new WebSocketClientFactory(); _conn = new SparseArray<Connection>(); _create = new ConnectionTask(_factory, _conn); _send = new SendingTask(_conn); _close = new DisconnectionTask(_conn); try { start(); } catch (Exception e) { } }
Example #10
Source File: WebSocket.java From WebSocket-for-Android with Apache License 2.0 | 5 votes |
@Override public void initialize(CordovaInterface cordova, final CordovaWebView webView) { super.initialize(cordova, webView); _factory = new WebSocketClientFactory(); _conn = new SparseArray<Connection>(); _executor = Executors.newSingleThreadExecutor(); _runner = new TaskRunner(); _runner.setTask(CREATE_TASK, new ConnectionTask(_factory, _conn)); _runner.setTask(SEND_TASK, new SendingTask(_conn)); _runner.setTask(CLOSE_TASK, new DisconnectionTask(_conn)); _runner.setTask(RESET_TASK, new ResetTask(_conn)); _runner.setTask(DESTROY_TASK, new DestroyTask(_factory, _conn)); _executor.execute(_runner); Log.setLogLevel(getLogLevel(this.preferences)); }
Example #11
Source File: SnsSqsMessageHandler.java From spring-integration-aws with MIT License | 4 votes |
@Override public void setConnection(Connection connection) { this.connection = connection; }
Example #12
Source File: SnsChannelMessageHandler.java From spring-integration-aws with MIT License | 4 votes |
@Override public void setConnection(Connection connection) { this.connection = connection; }
Example #13
Source File: SnsInboundMessageHandler.java From spring-integration-aws with MIT License | 4 votes |
@Override public void setConnection(Connection connection) { this.connection = connection; }
Example #14
Source File: GuacamoleWebSocketTunnelServlet.java From guacamole-client with Apache License 2.0 | 3 votes |
/** * Sends the given status on the given WebSocket connection * and closes the connection. * * @param connection * The WebSocket connection to close. * * @param guacStatus * The status to send. */ private static void closeConnection(Connection connection, GuacamoleStatus guacStatus) { closeConnection(connection, guacStatus.getGuacamoleStatusCode(), guacStatus.getWebSocketCode()); }
Example #15
Source File: GuacamoleWebSocketTunnelServlet.java From guacamole-client with Apache License 2.0 | 3 votes |
/** * Sends the given status on the given WebSocket connection * and closes the connection. * * @param connection * The WebSocket connection to close. * * @param guacStatus * The status to send. */ private static void closeConnection(Connection connection, GuacamoleStatus guacStatus) { closeConnection(connection, guacStatus.getGuacamoleStatusCode(), guacStatus.getWebSocketCode()); }
Example #16
Source File: GuacamoleWebSocketTunnelServlet.java From guacamole-client with Apache License 2.0 | 3 votes |
/** * Sends the given numeric Guacamole and WebSocket status * on the given WebSocket connection and closes the * connection. * * @param connection * The WebSocket connection to close. * * @param guacamoleStatusCode * The numeric Guacamole Status code to send. * * @param webSocketCode * The numeric WebSocket status code to send. */ private static void closeConnection(Connection connection, int guacamoleStatusCode, int webSocketCode) { connection.close(webSocketCode, Integer.toString(guacamoleStatusCode)); }
Example #17
Source File: GuacamoleWebSocketTunnelServlet.java From guacamole-client with Apache License 2.0 | 3 votes |
/** * Sends the given numeric Guacamole and WebSocket status * on the given WebSocket connection and closes the * connection. * * @param connection * The WebSocket connection to close. * * @param guacamoleStatusCode * The numeric Guacamole Status code to send. * * @param webSocketCode * The numeric WebSocket status code to send. */ private static void closeConnection(Connection connection, int guacamoleStatusCode, int webSocketCode) { connection.close(webSocketCode, Integer.toString(guacamoleStatusCode)); }
Example #18
Source File: DisconnectionTask.java From WebSocket-for-Android with Apache License 2.0 | 2 votes |
/** * Constructor * * @param map */ public DisconnectionTask(SparseArray<Connection> map) { _map = map; }
Example #19
Source File: SendingTask.java From WebSocket-for-Android with Apache License 2.0 | 2 votes |
/** * Constructor * * @param map */ public SendingTask(SparseArray<Connection> map) { _map = map; }
Example #20
Source File: ConnectionTask.java From IoTgo_Android_App with MIT License | 2 votes |
/** * Constructor * * @param factory * @param map */ public ConnectionTask(WebSocketClientFactory factory, SparseArray<Connection> map) { _factory = factory; _map = map; }
Example #21
Source File: DisconnectionTask.java From IoTgo_Android_App with MIT License | 2 votes |
/** * Constructor * * @param map */ public DisconnectionTask(SparseArray<Connection> map) { _map = map; }
Example #22
Source File: DestroyTask.java From WebSocket-for-Android with Apache License 2.0 | 2 votes |
/** * Constructor * * @param factory * @param map */ public DestroyTask(WebSocketClientFactory factory, SparseArray<Connection> map) { _factory = factory; _map = map; }
Example #23
Source File: ResetTask.java From WebSocket-for-Android with Apache License 2.0 | 2 votes |
/** * Constructor * * @param map */ public ResetTask(SparseArray<Connection> map) { _map = map; }
Example #24
Source File: SendingTask.java From IoTgo_Android_App with MIT License | 2 votes |
/** * Constructor * * @param map */ public SendingTask(SparseArray<Connection> map) { _map = map; }
Example #25
Source File: ConnectionTask.java From IoTgo_Android_App with MIT License | 2 votes |
/** * Constructor * * @param factory * @param map */ public ConnectionTask(WebSocketClientFactory factory, SparseArray<Connection> map) { _factory = factory; _map = map; }
Example #26
Source File: DisconnectionTask.java From IoTgo_Android_App with MIT License | 2 votes |
/** * Constructor * * @param map */ public DisconnectionTask(SparseArray<Connection> map) { _map = map; }
Example #27
Source File: SendingTask.java From IoTgo_Android_App with MIT License | 2 votes |
/** * Constructor * * @param map */ public SendingTask(SparseArray<Connection> map) { _map = map; }
Example #28
Source File: WebsocketHandler.java From spring-integration-aws with MIT License | votes |
public abstract void setConnection(Connection connection);