Hello All, because of the lot of questions asked by our users in jwebsocket forum regarding server side plugin development, i would like to list the simple eclipse based java project that uses jWebSocket and other jars as well as custom configuration to write a jWebSocket custom plugin in a separate small eclipse project. This also applies to any other IDE with few minor differences.
Download all the jWebSocket jars from our repository http://code.google.com/p/jwebsocket/downloads/detail?name=jWebSocketServer-0.10.zip&can=2&q= and all the dependency jars, if you are so impatient below is the snapshot of my eclipse project with hello world plugin.
So the above snapshot is the simple java project, which has jwebsocket and other libraries. Only thing that needs attention is jWebSocket.xml file in the conf folder, which is what we used to override the xml file that comes with jWebSocketServer.jar. In your conf/jWebSocket.xml jar you have to define your custom plugin say
<plugin> <name>com.plugins.HelloWorldPlugin</name></pre> <id>jws.custom</id> <ns>com.plugins.custom</ns> <jar>jWebSocketCustom-0.10.jar</jar> <server-assignments> <server-assignment>ts0</server-assignment> </server-assignments> </plugin>
NOTE that even though we are not using jar for our custom plugin you still have to specify it because of the known issue in jWebSocket.
Now to start the jWebSocket server you have to specify the jWebSocket main class in eclipse, From the eclipse menu select:
Run ->Run Configurations, then select Java Application which more or less looks like the snapshot below.
Specify the main class as org.jwebsocket.console.JWebSocketServer and in the arguments tab provide the -config argument value as the full path of your jWebSocket.xml file as
After that you can select Run->Your application configuration name above.
Here is the sample eclipse project which you can download and get started easily http://code.google.com/p/jwebsocket/downloads/detail?name=JWebSocketApp.zip&can=2&q=
I hope this will be helpful. Feel free to ask any questions or comments.