File tree Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5
+ <modelVersion >4.0.0</modelVersion >
6
+
7
+ <groupId >example-project</groupId >
8
+ <artifactId >example-project</artifactId >
9
+ <version >1.0-SNAPSHOT</version >
10
+
11
+ <repositories >
12
+ <repository >
13
+ <id >my.mvn.repo</id >
14
+ <url >https://github.com/keesun/mvn-repo/raw/master</url >
15
+ </repository >
16
+ </repositories >
17
+
18
+ <dependencies >
19
+ <dependency >
20
+ <groupId >com.nhncorp</groupId >
21
+ <artifactId >mod-socket-io</artifactId >
22
+ <version >1.0.0</version >
23
+ </dependency >
24
+ </dependencies >
25
+
26
+ </project >
Original file line number Diff line number Diff line change
1
+ package whiteship ;
2
+
3
+ import com .nhncorp .mods .socket .io .SocketIOServer ;
4
+ import com .nhncorp .mods .socket .io .SocketIOSocket ;
5
+ import com .nhncorp .mods .socket .io .impl .DefaultSocketIOServer ;
6
+ import org .vertx .java .core .Handler ;
7
+ import org .vertx .java .core .http .HttpServer ;
8
+ import org .vertx .java .core .json .JsonObject ;
9
+ import org .vertx .java .platform .Verticle ;
10
+
11
+ /**
12
+ * @author Keesun Baik
13
+ */
14
+ public class EchoServer extends Verticle {
15
+
16
+ @ Override
17
+ public void start () {
18
+ int port = 9999 ;
19
+ HttpServer server = vertx .createHttpServer ();
20
+ SocketIOServer io = new DefaultSocketIOServer (vertx , server );
21
+
22
+ io .sockets ().onConnection (new Handler <SocketIOSocket >() {
23
+ @ Override
24
+ public void handle (final SocketIOSocket socket ) {
25
+ socket .emit ("Hello" );
26
+ socket .on ("/news" , new Handler <JsonObject >() {
27
+ @ Override
28
+ public void handle (JsonObject data ) {
29
+ System .out .println (data );
30
+ socket .emit (data );
31
+ }
32
+ });
33
+ }
34
+ });
35
+
36
+ server .listen (port );
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments