I’ve done to write hello world of WebSocketServer (for html5 websocket) with Netty (a network framework by jboss) . It’s really simple to create. You start with 7 step to create WebSocketServer :
- S1 : Create new project with “HelloNetty” name
- S2 : Download documentation in : http://netty.io/docs/ and lib of Netty : http://netty.io/downloads/
- S3 : Create “lib” folder and paste 2 packages : “netty-3.4.4.Final-sources.jar” and
“netty-3.4.4.Final.jar” to “lib”
- S4 : Add lib and source preference :
- S4.1 : Add lib : Click right mouse to HelloWorld ->Build Path -> Configure Build Path
Choose “Libraries” tab -> Add JARs -> lib -> “netty-3.4.4.Final-source.jar”
- S4.2 : Add Source : choose lib package -> Source attachment -> Edit button -> Workspace -> choose source(netty-3.4.4.Final-source.jar) -> Ok button
- S5 : Create “src” folder” and paste 4 files : “WebSocketServer.java”, “WebSocketServerHandler.java”, “WebSocketServerIndexPage.java”, “WebSocketServerPipelineFactory.java” in there
- S6 : In Src, have 2 files that you need to care to edit : “WebSocketServerHandler.java” and “WebSocketServerIndexPage.java”
- S6.1 : In “WebSocketServerHandler.java” : we care to “handleWebSocketFrame()” method. This’s method that u can do. Cause it’s simple helloworld project, so, u can edit directly in this. But if your project has big, you should write others methods to clear seeing and easy manager, then, call those methods in this method.
- S6.2 : In “WebSocketServerIndexPage.java” : it’s client. But to easy, you can create new html in others folder to edit. Example, i create “test.html” file to test.
- S7 : Run and Test Server, Client
- S7.1 : Run Server : go to “WebSocketServer.java” file, and run.
- S7.2 : Run Client : go to “test.html” file, copy location of “test” file, and paste to browser to run
Source code in here : http://www.mediafire.com/?c434vlhd46cdc2y
Hope to helping ^^
could you make source code available on GitHub?