io.socket.client.Socket Java Examples
The following examples show how to use
io.socket.client.Socket.
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: RipeMonitors.java From onos with Apache License 2.0 | 9 votes |
@Override public void startMonitor() { if (!isRunning()) { log.info("Starting RIPE monitor for " + prefix + " / " + host); IO.Options opts = new IO.Options(); opts.path = "/stream/socket.io/"; try { this.socket = IO.socket("http://stream-dev.ris.ripe.net/", opts); this.socket.on(Socket.EVENT_CONNECT, args -> onConnect()); this.socket.on(Socket.EVENT_PONG, args -> socket.emit("ping")); this.socket.on("ris_message", this::onRisMessage); } catch (URISyntaxException e) { log.error("startMonitor()", e); } this.socket.connect(); } }
Example #2
Source File: VideoChatActivity.java From Socket.io-FLSocketIM-Android with MIT License | 7 votes |
private void requestServerCreateRoom(){ Socket socket = SocketManager.socket; JSONObject jsonObject = new JSONObject(); try { jsonObject.put("from_user", fromUser); jsonObject.put("to_user", toUser); } catch (JSONException e) { e.printStackTrace(); } socket.emit("videoChat", jsonObject, new Ack() { @Override public void call(Object... args) { String room = (String) args[0]; connectRoom(room); } }); }
Example #3
Source File: ChatFragment.java From LLApp with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); App app = (App) getActivity().getApplication(); mSocket = app.getSocket(); mSocket.on(Socket.EVENT_CONNECT,onConnect); mSocket.on(Socket.EVENT_DISCONNECT,onDisconnect); mSocket.on(Socket.EVENT_CONNECT_ERROR, onConnectError); mSocket.on(Socket.EVENT_CONNECT_TIMEOUT, onConnectError); mSocket.on("new message", onNewMessage); mSocket.on("user joined", onUserJoined); mSocket.on("user left", onUserLeft); mSocket.on("typing", onTyping); mSocket.on("stop typing", onStopTyping); mSocket.connect(); // startSignIn(); }
Example #4
Source File: ChatActivity.java From Socket.io-FLSocketIM-Android with MIT License | 6 votes |
@Override protected void onDestroy() { super.onDestroy(); ClientManager.chattingUserId = ""; EventBus.getDefault().unregister(this); KeyboardUtils.hideSoftInput(this); Socket socket = SocketManager.socket; socket.off("__join"); socket.off("_ice_candidate"); socket.off("_peers"); socket.off("_new_peer"); socket.off("_remove_peer"); socket.off("_offer"); socket.off("_answer"); socket.off("cancelVideoChat"); }
Example #5
Source File: MainFragment.java From socket.io-android-chat with MIT License | 6 votes |
@Override public void onDestroy() { super.onDestroy(); mSocket.disconnect(); mSocket.off(Socket.EVENT_CONNECT, onConnect); mSocket.off(Socket.EVENT_DISCONNECT, onDisconnect); mSocket.off(Socket.EVENT_CONNECT_ERROR, onConnectError); mSocket.off(Socket.EVENT_CONNECT_TIMEOUT, onConnectError); mSocket.off("new message", onNewMessage); mSocket.off("user joined", onUserJoined); mSocket.off("user left", onUserLeft); mSocket.off("typing", onTyping); mSocket.off("stop typing", onStopTyping); }
Example #6
Source File: MainFragment.java From socket.io-android-chat with MIT License | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); ChatApplication app = (ChatApplication) getActivity().getApplication(); mSocket = app.getSocket(); mSocket.on(Socket.EVENT_CONNECT,onConnect); mSocket.on(Socket.EVENT_DISCONNECT,onDisconnect); mSocket.on(Socket.EVENT_CONNECT_ERROR, onConnectError); mSocket.on(Socket.EVENT_CONNECT_TIMEOUT, onConnectError); mSocket.on("new message", onNewMessage); mSocket.on("user joined", onUserJoined); mSocket.on("user left", onUserLeft); mSocket.on("typing", onTyping); mSocket.on("stop typing", onStopTyping); mSocket.connect(); startSignIn(); }
Example #7
Source File: NSClientService.java From AndroidAPS with GNU Affero General Public License v3.0 | 6 votes |
public synchronized void destroy() { if (mSocket != null) { mSocket.off(Socket.EVENT_CONNECT); mSocket.off(Socket.EVENT_DISCONNECT); mSocket.off(Socket.EVENT_PING); mSocket.off("dataUpdate"); mSocket.off("announcement"); mSocket.off("alarm"); mSocket.off("urgent_alarm"); mSocket.off("clear_alarm"); RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "destroy")); isConnected = false; hasWriteAuth = false; mSocket.disconnect(); mSocket = null; } }
Example #8
Source File: ChatFragment.java From LLApp with Apache License 2.0 | 6 votes |
@Override public void onDestroy() { super.onDestroy(); mSocket.disconnect(); mSocket.off(Socket.EVENT_CONNECT, onConnect); mSocket.off(Socket.EVENT_DISCONNECT, onDisconnect); mSocket.off(Socket.EVENT_CONNECT_ERROR, onConnectError); mSocket.off(Socket.EVENT_CONNECT_TIMEOUT, onConnectError); mSocket.off("new message", onNewMessage); mSocket.off("user joined", onUserJoined); mSocket.off("user left", onUserLeft); mSocket.off("typing", onTyping); mSocket.off("stop typing", onStopTyping); }
Example #9
Source File: SocketManager.java From Socket.io-FLSocketIM-Android with MIT License | 6 votes |
public static void connect(String token, final SocketCallBack callBack){ SocketManager.callBack = callBack; if (socket == null) { initSocket(token); } else { socket = null; initSocket(token); } socket.once(Socket.EVENT_CONNECT, new Emitter.Listener() { @Override public void call(Object... args) { callBack.success(); } }); socket.connect(); addHandles(); }
Example #10
Source File: SocketService.java From zephyr with MIT License | 5 votes |
private void setUpEvents() { mSocket.on(Socket.EVENT_CONNECT, args -> { logger.log(LogLevel.DEBUG, LOG_TAG, "Connected to server."); if (!preferenceManager.getBoolean(PreferenceKeys.PREF_EVER_CONNECTED_TO_SERVER)) { preferenceManager.putBoolean(PreferenceKeys.PREF_EVER_CONNECTED_TO_SERVER, true); } updateServiceNotification(ConnectionStatus.CONNECTED); }).on(Socket.EVENT_DISCONNECT, args -> { logger.log(LogLevel.DEBUG, LOG_TAG, "Disconnected from server."); updateServiceNotification(ConnectionStatus.DISCONNECTED); }); }
Example #11
Source File: MyAccessibility.java From MiHomePlus with MIT License | 5 votes |
/** * Socket */ private void initSocketHttp() { // 休眠后會斷線… 》小米手機的神隱模式「https://kknews.cc/tech/zpav83.html」 // 從配置文件讀取伺服器地址 SharedPreferences settings = getSharedPreferences(data, 0); Hosts = settings.getString(addressField, ""); Log.i(TAG, "initSocketHttp: Hosts: " + Hosts); try { mSocket = IO.socket(Hosts); } catch (URISyntaxException e) { e.printStackTrace(); } mSocket.on(Socket.EVENT_CONNECT, onConnect); mSocket.on(Socket.EVENT_DISCONNECT, onDisconnect);// 断开连接 mSocket.on(Socket.EVENT_CONNECT_ERROR, onConnectError);// 连接异常 mSocket.on(Socket.EVENT_CONNECT_TIMEOUT, onConnectTimeoutError);// 连接超时 mSocket.on("update", onUpdate); mSocket.on("Ping", onPing); mSocket.connect(); }
Example #12
Source File: SocketSignalingChannel.java From owt-client-android with Apache License 2.0 | 5 votes |
@Override public void disconnect() { if (socketIOClient != null) { Log.d(TAG, "Socket IO Disconnect."); socketIOClient.on(Socket.EVENT_DISCONNECT, onDisconnectCallback); socketIOClient.disconnect(); socketIOClient = null; } }
Example #13
Source File: SocketSignalingChannel.java From owt-client-android with Apache License 2.0 | 5 votes |
@Override public void disconnect() { if (socketIOClient != null) { Log.d(TAG, "Socket IO Disconnect."); socketIOClient.on(Socket.EVENT_DISCONNECT, onDisconnectCallback); socketIOClient.disconnect(); socketIOClient = null; } }
Example #14
Source File: ExaBgpMonitors.java From onos with Apache License 2.0 | 5 votes |
@Override public void startMonitor() { if (!isRunning()) { log.info("Starting EXA monitor for " + prefix + " / " + host); try { this.socket = IO.socket("http://" + this.host + "/onos"); this.socket.on(Socket.EVENT_CONNECT, args -> onConnect()); this.socket.on(Socket.EVENT_PING, args -> socket.emit("pong")); this.socket.on("exa_message", this::onExaMessage); } catch (URISyntaxException e) { log.warn("startMonitor()", e); } this.socket.connect(); } }
Example #15
Source File: VideoChatHelper.java From Socket.io-FLSocketIM-Android with MIT License | 5 votes |
/** * 加入房间 * * @param room 房间号 */ private void joinRoom(String room) { Socket socket = SocketManager.socket; JSONObject object = new JSONObject(); try { object.put("room", room); } catch (JSONException e) { FLLog.i("加入房间失败!!!"); e.printStackTrace(); } socket.emit("__join", object); }
Example #16
Source File: ConnectListener.java From 07kit with GNU General Public License v3.0 | 4 votes |
public ConnectListener(ClientService clientService) { super(Socket.EVENT_CONNECT, clientService); }
Example #17
Source File: DisconnectListener.java From 07kit with GNU General Public License v3.0 | 4 votes |
public DisconnectListener(ClientService clientService) { super(Socket.EVENT_DISCONNECT, clientService); }
Example #18
Source File: ClientService.java From 07kit with GNU General Public License v3.0 | 4 votes |
public Socket getSocket() { return socket; }
Example #19
Source File: SimpleListener.java From 07kit with GNU General Public License v3.0 | 4 votes |
public Socket getSocket() { return clientService.getSocket(); }
Example #20
Source File: App.java From LLApp with Apache License 2.0 | 4 votes |
public Socket getSocket() { return mSocket; }
Example #21
Source File: NSClientService.java From AndroidAPS with GNU Affero General Public License v3.0 | 4 votes |
public void initialize() { dataCounter = 0; readPreferences(); if (!nsAPISecret.equals("")) nsAPIhashCode = Hashing.sha1().hashString(nsAPISecret, Charsets.UTF_8).toString(); RxBus.INSTANCE.send(new EventNSClientStatus("Initializing")); if (!NSClientPlugin.getPlugin().isAllowed()) { RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "not allowed")); RxBus.INSTANCE.send(new EventNSClientStatus("Not allowed")); } else if (NSClientPlugin.getPlugin().paused) { RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "paused")); RxBus.INSTANCE.send(new EventNSClientStatus("Paused")); } else if (!nsEnabled) { RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "disabled")); RxBus.INSTANCE.send(new EventNSClientStatus("Disabled")); } else if (!nsURL.equals("") && (MainApp.engineeringMode || nsURL.toLowerCase().startsWith("https://"))) { try { RxBus.INSTANCE.send(new EventNSClientStatus("Connecting ...")); IO.Options opt = new IO.Options(); opt.forceNew = true; opt.reconnection = true; mSocket = IO.socket(nsURL, opt); mSocket.on(Socket.EVENT_CONNECT, onConnect); mSocket.on(Socket.EVENT_DISCONNECT, onDisconnect); mSocket.on(Socket.EVENT_ERROR, onError); mSocket.on(Socket.EVENT_CONNECT_ERROR, onError); mSocket.on(Socket.EVENT_CONNECT_TIMEOUT, onError); mSocket.on(Socket.EVENT_PING, onPing); RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "do connect")); mSocket.connect(); mSocket.on("dataUpdate", onDataUpdate); mSocket.on("announcement", onAnnouncement); mSocket.on("alarm", onAlarm); mSocket.on("urgent_alarm", onUrgentAlarm); mSocket.on("clear_alarm", onClearAlarm); } catch (URISyntaxException | RuntimeException e) { RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "Wrong URL syntax")); RxBus.INSTANCE.send(new EventNSClientStatus("Wrong URL syntax")); } } else if (nsURL.toLowerCase().startsWith("http://")) { RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "NS URL not encrypted")); RxBus.INSTANCE.send(new EventNSClientStatus("Not encrypted")); } else { RxBus.INSTANCE.send(new EventNSClientNewLog("NSCLIENT", "No NS URL specified")); RxBus.INSTANCE.send(new EventNSClientStatus("Not configured")); } }
Example #22
Source File: ClusterListener.java From ignite with Apache License 2.0 | 4 votes |
/** * @param client Client. * @param restExecutor REST executor. */ public ClusterListener(AgentConfiguration cfg, Socket client, RestExecutor restExecutor) { this.cfg = cfg; this.client = client; this.restExecutor = restExecutor; }
Example #23
Source File: SignalingChannel.java From owt-client-android with Apache License 2.0 | 4 votes |
void disconnect() { if (socketClient != null) { socketClient.on(Socket.EVENT_DISCONNECT, disconnectCallback); socketClient.disconnect(); } }
Example #24
Source File: ChatApplication.java From socket.io-android-chat with MIT License | 4 votes |
public Socket getSocket() { return mSocket; }