Build the sample applications

If you are new to PureWeb, we recommend that you begin by building and exploring one of the sample applications.

These applications are simple yet fully functional, they contain features that illustrate all the fundamentals, and they provide you with a base code that you can incorporate into your own applications, rather than start with a completely blank slate.

Most of the code snippets in the documentation come from these sample applications.

The instructions on this page will place the sample service on the same node as the PureWeb server. If you need a working sample where these two components reside on different nodes (this is only supported if working with the C++ or .Net Scribble sample on Windows), follow the instructions here.

Steps

Choose a sample

Which sample application you can build depends on your choice of operating system and programming language. The main sample is Scribble; it is available across all platforms.

You can mix and match any sample service with any sample client; for instance the Scribble client on iOS works just as well when paired with the Java service on Windows as with the C++ service on Linux.

The table below summarizes service and client availability per operating system.

Windows Linux iOS

Service

Scribble: C++, .Net, Java

Asteroids: Java

Client

Scribble: HTML5, Android, Flex

Asteroids: HTML5, Android

Service

Scribble: C++

Client

Scribble: HTML5, Flex

 

Service

n/a

Client

Scribble (Objective-C and Swift)

Asteroids (Swift)

Scribble is a simple canvas which allows users to draw, change pen color, and erase drawings.

Asteroids is an implementation of the classic video game with a twist -- it supports both single-player and two-player modes; each player independently controls his or her own ship.

See Explore the samples for a more detailed description of the functionality.


Build the service

Before building the sample service, it is a good idea to first double-check that your development environment meets the system requirements, and that any relevant environment variable is pointing to the right path.

If you installed PureWeb in the default location, the install path is C:\CSI\PureWeb (on Windows) or /opt/CSI/PureWeb (on Linux).

C++ (Windows)

The C++ sample service on Windows is packaged as a Visual Studio solution.

  1. Navigate to the location of the source files:
    [install_path]\SDK\Samples\Scribble\ScribbleAppCpp
  2. Double-click the ScribbleApp2010.sln file to open it in Microsoft Visual Studio.
  3. Go to the Build menu, then select Build Solution. You can keep an eye on Visual Studio's output pane, which will confirm if the build was successful.

This will place the files for your service at this location:
[install_path]\Server\bin\ScribbleAppCpp

It also adds the application plug-in file to the PureWeb server:
[install_path]\Server\conf\ScribbleAppCpp-plugin.xml

C++ (Linux)

The C++ sample service on Linux is packaged as a Qt project.

  1. Copy the sample directory to your home directory:
    cp -r /[install_path]/SDK/Samples/Scribble/ScribbleAppQt ~/ScribbleAppQt
  2. Change to the copied directory:
    cd ~/ScribbleAppQt
  3. Build the sample:
    • On Red Hat: qmake-qt4; make
    • On Ubuntu: qmake; make
  4. Deploy the sample to the PureWeb server:
    sudo -E ./deploy.sh

This will place files for your service at this location:
[install_path]/Server/bin/ScribbleAppQt

It also adds the application plug-in file to the PureWeb server:
[install_path]/Server/conf/ScribbleAppQt-plugin.xml

.Net

The .Net sample service on Windows is packaged as a Visual Studio solution.

  1. Navigate to the location of the source files:
    [install_path]\SDK\Samples\Scribble\ScribbleAppCSharp
  2. Double-click the ScribbleApp2010.sln file to open it in Microsoft Visual Studio.
  3. Go to the Build menu, then select Build Solution. You can keep an eye on Visual Studio's output pane, which will confirm if the build was successful.

This will place files for your service at this location:
[install_path]\Server\bin\ScribbleApp

It also adds the application plug-in file to the PureWeb server:
[install_path]\Server\conf\ScribbleApp-plugin.xml

Java

These instructions install the sample services using Ant on Windows. It is also possible to build using Eclipse.

  1. Open a console (command prompt) window and change the directory to the location of the source files:
    [install_path]\SDK\Samples\Java
  2. Type ant to run the build.xml script.

This generates a .jar file in the \dist sub-directory:
CSI.PureWeb.Server.Samples.jar

It also adds the application plug-in file to the PureWeb server:
[install_path]\Server\conf\JavaSamples-plugin.xml

Verify that it worked

If the server is already running, you do not need to restart it. Instead, simply reload the plug-ins (navigate to the server's Configuration page and click the Reload Plugins button). Otherwise if the server is not running, start it now and log in.

You should now see your sample service in the Apps page of the PureWeb server, under Available Managed Applications.

If this doesn't work, there is a knowledge base article that may help you pinpoint what went wrong.

If you click a launch button, the server will display an error because you haven't built the client yet, but it will still launch the service (which should automatically time out after 30 seconds).


Build the client

Before building the sample client, it is a good idea to first double-check that your development environment meets the system requirements, and that any relevant environment variable is pointing to the right path.

The Flex client is deprecated, but instructions on how to build it are still available here.

HTML5 (Windows)

To build the HTML5 client on Windows, you simply run a batch file:

  1. Navigate to the location of the source files for the sample that you want to build:
    [install_path]\SDK\Samples\Scribble\ScribbleClientHTML5
    [install_path]\SDK\Samples\Asteroids\AsteroidsClientHTML5

  2. Double-click the deploy.bat file.

You should now see the files for ScribbleApp or AsteroidsApp (including the .html and .js ) in the following folder:
[install_path]\Server\webapp

HTML5 (Linux)

To build the HTML5 client on Linux, you simply run a shell script:

  1. Navigate to the location of the source files:
    [install_path]/SDK/Samples/Scribble/ScribbleClientHTML5

  2. Run the following command:
    sudo -E ./deploy.sh

You should now see the files for ScribbleApp (including the .html and .js ) in the following folder:
[install_path]/Server/webapp

iOS

If you haven't already, clone the source GitHub repository:
https://github.com/calgaryscientific/pureweb-ios-samples

  1. In Terminal, navigate to the location where you cloned the repository. Type the following command to install the pods:
    pod install
    This will dynamically generate the sample workspace (PureWebSamples.xcworkspace) at the root of the samples directory.

  2. In Finder, double-click PureWebSamples.xcworkspace to launch the project in Xcode.
  3. In Xcode, select the application that you want to build, Scribble or Asteroids.

  4. Go to the Product menu and select Build to build the selected application.
  5. To run the application, go to the Product menu and choose Run. This will install the client into the Apple iPhone Simulator.

An icon for the app should now appear in the simulator. Before you can use the app and connect to the service application, you need to configure a few settings, as described in Launch the application, below.

Android

These instructions assume that you are connecting an Android device to your computer. Ensure that USB debugging is enabled on that device (see https://developer.android.com/studio/run/device.html). If you plan to use an Android Virtual Device (AVD) rather than an actual device, you'll find the instructions for using the emulator in the Android developer documentation.

Remember that when building the Android sample clients, API level 21 should be installed, as described in the Requirements.

  1. Plug the Android device into your computer.
  2. Launch Android Studio.
  3. Select Open an existing Android Studio project from the Quick Start menu (or go to File | Open).
  4. Navigate to the location of the source files:
    [install_path]\SDK\Samples\Android
  5. Open the project for the sample of your choice: scribble or asteroids.
  6. Click the Run button.
  7. When prompted to choose a device, choose the device connected to your computer (or a virtual device if you created one).

    If Android Studio is showing your connected device as offline, check the device. It may be displaying a prompt about allowing USB debugging. Choose to allow and click OK.

  8. Once the connected device is online, click OK in the Device Chooser dialog. An icon for the app should now appear on the device. Before you can use the app and connect to the service application, you need to configure a few settings, as described in Launch the application, below.

Launch the application

For browser-based clients, you can simply launch the application through the PureWeb server.

On mobile apps, before you can connect the client to the PureWeb server and start a session, you must first provide information in the app's settings so that it knows where the find the server.

HTML5

In the PureWeb server, click the Apps link to display the list of available applications.

Click the "launch html5" button associated with the sample service application that you built earlier.
(To launch the application with the Diagnostics Panel enabled, add the &_diagnostics=true parameter at the end of the URL.)

iOS

Once the app is available in the Apple iPhone Simulator, go to the device's Settings and edit the app's configuration as follows:

  • In the Server URL field, enter one of the following values, depending on which service you are accessing (.Net, C++ or Java). Replace the "hostname" and "port" placeholders with the actual values for your PureWeb server — do not use "localhost":

    • http://[hostname]:[port]/pureweb/app?name=ScribbleApp
      http://[hostname]:[port]/pureweb/app?name=ScribbleAppCpp
      http://[hostname]:[port]/pureweb/app?name=ScribbleAppJava
      http://[hostname]:[port]/pureweb/app?name=AsteroidsAppJava
  • In the Username and Password fields, enter the credentials to access the PureWeb server (this is only necessary if these were changed to something other than the default admin value).

If the PureWeb server uses a secure HTTPS connection, you will also need to enable the Secure Collaboration setting.

When you are done with the settings, return to the device's home page and double-click the app to launch it.

The app will display the login page, click Connect; this will automatically start the service and connect the app to it.

Android

Once the app is available on the device, click its icon to launch it; this will display the login page. From this page, click the menu button on the top right and select the Settings option.

  • In the Server URL field, enter one of the following values, depending on which Scribble service you are accessing (.Net, C++ or Java). Replace the "hostname" and "port" placeholders with the actual values for your PureWeb server — do not use "localhost":

    • http://[hostname]:[port]/pureweb/app?name=ScribbleApp
      http://[hostname]:[port]/pureweb/app?name=ScribbleAppCpp
      http://[hostname]:[port]/pureweb/app?name=ScribbleAppJava
  • In the User Name and Password fields, enter the credentials to access the PureWeb server (this is only necessary if these were changed to something other than the default admin value).

If the PureWeb server uses a secure HTTPS connection, you will also need to enable the Secure Collaboration setting.

When you are done with the settings, press the back button to return to the login page.

From the login page, click Connect to launch the application. This will automatically start the service and connect the app to it.

If the sample application doesn't launch, there is a knowledge base article that may help you pinpoint what went wrong.