Introduction

The Newbound Network is a Peer-to-Peer (P2P) framework for web apps. The software includes an HTTP server on port 5773 and a set of default apps that provide the core Newbound Network functionality, including P2P communication, security/encryption, data storage, file transfer, port-forwarding, app publishing and much more.

The framework is self-contained in a single JAR file, and when launched will create a working directory called “Newbound” in the appropriate location as deemed by your Operating System on Mac or Windows (Linux uses your user’s home directory). A single subdirectory of the Newbound directory called “botd” is created to store all runtime data needed by the software. Inside the botd directory you will find one subdirectory for each Newbound Network app installed.

Everything in the Newbound Network software is designed so that you can use as much or as little of it as you want, so if all you need is a quick and easy web server you can just drop your files in the “Newbound/botd/botmanager/html” folder and they will be available at the url “http://localhost:5773/botmanager/[your file name]”.

The software will automatically establish a peer identity and attempt to connect to the Newbound Network. Once connected, you will be able to connect your device to other devices running the Newbound Network and establish exactly what apps and services you want those devices to have access to.

All apps in the Newbound Network are written in HTML5 with an API of commands available via javascript. The commands are written in Java and typically return JSON responses.

The software also includes an app builder where you can easily just “drop in” your HTML, CSS, Javascript and Java commands, then hit “publish” and your app is immediately available to anyone you’re connected to over the Newbound Network.

Deploying an app manually

The “use as little or as much as you like” and the “drop your code in here” philosophies are very important to us, so we wanted to make it as simple as possible to get started, without learning a bunch of framework stuff. If you’re not interested in how the Newbound Network organizes apps under the hood, skip to the “Deploying an app using the MetaBot” section below.

Each app in the Newbound Network is a subclass of the com.newbound.robot.BotBase class, which requires at a minimum that your app provide a unique service id and the name of your index file. You can override the “handleCommand” function to implement the commands in your app’s API. At startup, the BotBase class will look for the subdirectory of “Newbound/botd” named for its service id, and load its runtime properties from a file in that folder called “botd.properties”.

The following is the minimum configuration required to get the Newbound Network to recognize your app:

Example App, “My App”
App Name: My App
Service ID: myapp001
Index File: index.html
Class File: com.mycompany.MyApp001.class (subclass of com.newbound.robot.BotBase)
App Icon: myapp001.png

Step 1 – Build JAR file

Name your JAR file myapp001_1.jar and place it in the Newbound/botd/botmanager/jars folder.

Your JAR file should contain the following files:

com/mycompany/MyApp001.class
html/myapp001/index.html
html/myapp001/myapp001.png

NOTE: You can add as many other class files as you like, and any files you drop in the “html/myapp001” folder will be served up by the web server.

Step 2 – Prepare App Properties File

Now you need to create a new file called app.properties and place it in a new folder you create at Newbound/botd/myapp001 with the following contents:

name=My App
id=myapp001
botclass=com.mycompany.MyApp001
img=/myapp001/myapp001.png
desc=The My App application
version=1

Step 3 – Activate Your App

Once those few requisite files are in place, the only thing required to activate your app is to edit the Newbound/botd/botmanager/botd.properties file and add your class name to the end of the “bots” property. That line should look something like the following:

Step 4 – Restart the Newbound Network

“Soft launching” your app is beyond the scope of this tutorial, so just restart your instance of the Newbound Network. When your App Manager comes up, you’ll have a new app on the menu.

Congratulations! You just successfully deployed an app manually on the Newbound Network!

Deploying an app using the MetaBot

The MetaBot is a handy little app for creating P2P web app content, assembling content into an app, and publishing apps on the Newbound Network. It’s not really meant to be a full fledged IDE, although it can be used as one. However, if your java is more than a few lines of code, you will probably want to develop your class library in your IDE of choice and just include it in your jar file.

This example assumes you built your app using an IDE and you just want to publish it using the MetaBot. If you don’t want to build your app using a separate IDE, and you just want to “drop your code in here”, skip to the “Building Apps with the MetaBot” section below.

Step 1 – Prepare the Source Directory

Basically, everything that ends up in the JAR file in the example above, goes into the Newbound/botd/myapp001/src folder instead. Any Java files will be compiled by the MetaBot for you.

com/mycompany/MyApp001.java
html/myapp001/index.html
html/myapp001/myapp001.png

NOTE: You can add as many other java and/or class files as you like, and any files you drop in the “html/myapp001” folder will be served up by the web server.

Step 2 – Publish your App

Open up the MetaBot, click on the “Libraries” tab and add a new Library named “myapp001”. Open your new library and add a control named “myapp001”. Click on the “Publish” tab and enter the following:

NOTE: Make sure you TURN OFF the “Generate HTML” and “Generate Java” checkboxes, or else MetaBot will overwrite those files!

Click the “publish” button and you’re just a restart away from running and sharing your new app.

Step 3 – Restart the Newbound Network

“Soft launching” your app is beyond the scope of this tutorial, so just restart your instance of the Newbound Network. When your App Manager comes up, you’ll have a new app on the menu.

Congratulations! You just successfully deployed an app with the MetaBot on the Newbound Network!

Building Apps with the MetaBot

Building an app using the MetaBot is Toaster Simple™ to do!

Open up the MetaBot, click on the “Libraries” tab and add a new library named “myapp001”. Open your new library and add a control named “myapp001”. Click on the “NEW COMMAND” button, name it “hello”, add it and then enter the following:

Click on the “HTML” tab and enter the following:

Click on the CSS tab and enter the following:

Click on the Javascript tab and enter the following:

You can preview your work by clicking on the “Preview” tab:

Click on the “Publish” tab and enter the following:

Finally, drop an icon for your app named myapp001.png in the folder Newbound/botd/myapp001/src/html/myapp001/.

“Soft launching” your app is beyond the scope of this tutorial, so just restart your instance of the Newbound Network. When your App Manager comes up, you’ll have a new app on the menu.

Congratulations! You just successfully built and deployed an app with the MetaBot on the Newbound Network!

Related Links