jWebSocket Step-By-Step – Part 1
. The aim of this article is to focus more on how to use it and get started and understand the various nitty gritty of jWebSocket usage.
So, how do i set it up quickly and run it?? Well, if you cannot wait at all then we have few demos in our product site that you can try without even bothering to set it up in your machine. But, if you want to try the thick and thing here are steps to follow:
Download the latest zip file jWebSocketServer-0.9.0.zip from here
for the server and jWebSocketClient-0.9.0.zip from here
. After you download and extract it you will see the folder structure like this.
As you can see there are basically 4 folders
- bin - contains the batch file to run the server
- conf – contains the configuration file ‘jWebSocket.xml‘, I will discuss more about it later.
- libs – this folder contains all the jar files of different modules in jWebSocket, bundle jar and war for web application.
- logs – folder that contains log settings.
1. Standalone Server - Whichever mode you want to use, first set the environment variable JWEBSOCKET_HOME to the base location of your jWebSocket-0.9.0 folder(eg: /Users/puran/jWebSocket-0.9.0). To run as stand alone server, simply execute the batch/script file from the bin directory of the jWebSocket folder. If every thing is honky dory your stand alone server should start successfully at port 8787. My Console looks something like this.
Now to test our stand alone jWebSocket server open any of the demo html files from jWebSocketClient-0.9.0 package you downloaded above. For example if I open file like file:///Users/puran/projects/jwebsockets/jWebSocket/jWebSocketClient-0.9.0/demos/chat/chat.htm then you should be able to login to the chat window as shown below.
2. jWebSocket embedded in Web Application
– This option allows you to run jWebSocket Server as an web application in your Tomcat server so that it’s easier to integrate with other web applications.To do this simply copy the jWebSocketAppSrvDemo-0.9.0.war
file from JWEBSOCKET_HOME/libs folder to the webapp folder of your tomcat installation. Now copy the jar file jWebSocketServer-Bundle-0.9.0.jar
from the same libs folder to the lib folder of your tomcat. This single bundle jar bundles all the required libraries to run jWebSocket. Now at this moment we will not change any configuration whatsoever and just run with the default settings and configuration. Start your tomcat server and point your browser to http://localhost:8080/jWebSocketAppSrvDemo-0.9.0/
. If everything is setup properly then you should see the home page with few demos.