-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSocketIoClient.java
More file actions
53 lines (38 loc) · 1.33 KB
/
SocketIoClient.java
File metadata and controls
53 lines (38 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package ru.ids360.x360FileStorage;
import io.socket.client.IO;
import io.socket.client.Socket;
import io.socket.emitter.Emitter;
import java.net.URISyntaxException;
/**
* Created by korolev on 25.10.16.
*/
public class SocketIoClient {
Socket socket = null;
public Socket createSocket () throws URISyntaxException {
IO.Options opts = new IO.Options();
//opts.transports = new String [] {"websocket"};
opts.query ="workspace=123";
opts.path = "/fileStorage";
socket = IO.socket("http://127.0.0.1:3000", opts);
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
socket.emit("foo", "hi");
socket.disconnect();
}
}).on("event", new Emitter.Listener() {
@Override
public void call(Object... args) {}
}).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {}
});
socket.connect();
return socket;
}}
public static void main(String[] args) throws URISyntaxException {
SocketIoClient socketIoClient = new SocketIoClient();
Socket currentSocket = socketIoClient.createSocket();
//currentSocket.close();
}
}