Home III. Installation guide

III. Installation guide

a. Download

Download the latest version of JsRS from here. Once you’ve downloaded, unzip the archive to your local drive. Eg: C:\jsrs-1.0\

 

b. File structure

I always believe that the file structure will determine how complicated your software is. So I’ll try to keep the file structuring as simple as possible. Here it is:
  • /jsrs-x.y
    • /Javascript
      • Index.html
      • jsrs.js
    • /Proxy
      • /Client
        • Abstract.php
        • Standard.php
      • /Helper
        • Abstract.php
        • ServerBroker.php
      • Abstract.php
      • Exception.php
      • Helper.php
      • proxy.php
      • Services_JSON.php
    • /Server
      • /Message
      • Client.php
      • Connection.php
      • ConnectionManager.php
      • Exception.php
      • Function.php
      • Server.php
      • Services_JSON.php
    • /license.txt
    • Release Note.txt


For Proxy and Server, the class name is according to the file structure. Example Jsrs_Proxy_Client_Abstract (class name) is placed under /Proxy/Client/Abstract.php.

Note: Where the x.y is the version number. x is the major version while the y is the minor version number.

 

c. Starting the server

Alright, it's time to make the server alive! Launch your command-line interface. Depending on which platform you using, the steps are almost the same:

Windows

  • Change directory to your extracted archive, eg:
    >cd C:\jsrs-1.0\Server\
  • Execute the server using php executable file; php.exe
    >C:\php\php.exe -q Server.php
  • Note: The example given above assumes that your php executable file are located in C:\php, it could be somewhere else.
  • If the server is running, you should see a message like this:
    2010-07-26 16:45:32 JavaScript Remote Socket is Running!
  • Note: DO NOT close the windows as the server is running.
  • You can also create a batch file to start the server. This will save your time to typing the same command line each time you starting the server.
Linux
  • Change directory to your extracted archive, eg:
    $ cd /home/user/downloads/jsrs-1.0/Server
  • Execute the server using php command; php
    $ php -q Server.php
  • If the server is running, you should see a message like this:
    2010-07-26 16:45:32 JavaScript Remote Socket is Running!
  • If you would like to run the server without typing it, edit the server.php by adding the following line in the header of the file:
    #!/usr/bin/php -q
    <?php ...
  • Make the server.php executable (chmod 755) and rename it as jsrs_server then run it:
    $ ./jsrs_server

Note: For demo purposes, we want the server screen to be shown all the time so that we know what is happening. For production, please refer to the documentation on how to configure a production server.

 

d. Testing the connection

In order to test your server whether is it working or not, copy or move the “/Proxy” folder to your web directory. Eg: C:\Inetpub\wwwroot\ (windows) or /var/www/html/ (linux).

It is depending on how you setting up your application. As long the proxy file are accessible within the domain (not cross domain, eg: www.domain1.com accessing proxy on www.domain2.com).
Copy the “jsrs.js” to your web drive too.  You may want to put it under your Javascript folder. The last item is the “index.html” under “/Javascript” folder. Place it under the same directory with your JavaScript file.
Now your directory will look like this:
  • /your-web-drive
    • /Proxy
    • /Javascript
      • jsrs.js
      • index.html
    • <all your web drive’s files and folders>


Once you’ve placed all the files accordingly, go to the URL that point to your webdrive’s root directory:
http://localhost/ your-web-drive/Javascript/index.html

 

You should see a form with buttons and textbox. With your server running, click on “Connect” button. You should see the message “Connected to server with the ID: <session ID>”. Congratulation, your socket server is working!

 

To have fun with the demo, open up another browser (must be different browser), go to the same URL, and click Connect.
The moment you clicked “Connect”, you will see the client’s ID appear on the right text list. The ID is the client that connected to the server. Select the client’s ID and click on the remote function at the bottom of the textbox.

Note: Where the x.y is the version number. x is the major version while the y is the minor version number.
Last modified on Monday, 09 August 2010 22:10