-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Keesun Baik
committed
Jul 12, 2013
1 parent
bc5de45
commit b74a0ac
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>example-project</groupId> | ||
<artifactId>example-project</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<repositories> | ||
<repository> | ||
<id>my.mvn.repo</id> | ||
<url>https://github.com/keesun/mvn-repo/raw/master</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.nhncorp</groupId> | ||
<artifactId>mod-socket-io</artifactId> | ||
<version>1.0.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package whiteship; | ||
|
||
import com.nhncorp.mods.socket.io.SocketIOServer; | ||
import com.nhncorp.mods.socket.io.SocketIOSocket; | ||
import com.nhncorp.mods.socket.io.impl.DefaultSocketIOServer; | ||
import org.vertx.java.core.Handler; | ||
import org.vertx.java.core.http.HttpServer; | ||
import org.vertx.java.core.json.JsonObject; | ||
import org.vertx.java.platform.Verticle; | ||
|
||
/** | ||
* @author Keesun Baik | ||
*/ | ||
public class EchoServer extends Verticle { | ||
|
||
@Override | ||
public void start() { | ||
int port = 9999; | ||
HttpServer server = vertx.createHttpServer(); | ||
SocketIOServer io = new DefaultSocketIOServer(vertx, server); | ||
|
||
io.sockets().onConnection(new Handler<SocketIOSocket>() { | ||
@Override | ||
public void handle(final SocketIOSocket socket) { | ||
socket.emit("Hello"); | ||
socket.on("/news", new Handler<JsonObject>() { | ||
@Override | ||
public void handle(JsonObject data) { | ||
System.out.println(data); | ||
socket.emit(data); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
server.listen(port); | ||
} | ||
} |