diff --git a/.gitignore b/.gitignore index 7465cb2c..5763c839 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vscode _authortools -/_examples/**/node_modules -.directory \ No newline at end of file +.directory +node_modules +package-lock.json \ No newline at end of file diff --git a/_examples/websocket/basic/README.md b/_examples/websocket/basic/README.md new file mode 100644 index 00000000..948b18bc --- /dev/null +++ b/_examples/websocket/basic/README.md @@ -0,0 +1,62 @@ +# Basic Example + +At the end of this example you will be able to run a websocket server +and clients for all platforms (Go, Browser and Nodejs). + +![](overview.png) + +Open as many clients as you want to try out and start typing. + +This example contains only the basics, however, the library supports rooms, native websocket messages, any data can be sent and received (i.e protobufs, json) and all kinds of broadcasting and connections collections. + +## How to run + +### Server + +Open a terminal window instance and execute: + +```sh +$ go run server.go # start the websocket server. +``` + +### Client (Go) + +Start a new terminal instance and execute: + +```sh +$ cd ./go-client +$ go run client.go # start the websocket client. +# start typing... +``` + +### Client (Browser) + +Navigate to and start typing. +The `./browser/index.html` should be served, it contains the client-side code. + +### Client (Browserify) + +Install [NPM](https://nodejs.org) first, then start a new terminal instance and execute: + +```sh +$ cd ./browserify +$ npm install +# build the modern browser-side client: +# embed the neffos.js node-module and app.js +# into a single ./browserify/bundle.js file +# which ./browserify/client.html imports. +$ npm run-script build +``` + +Navigate to and start typing. + +### Client (Nodejs) + +Install [NPM](https://nodejs.org) if you haven't already and then, start a new terminal instance and execute: + +```sh +$ cd nodejs-client +$ npm install +$ node client.js # start the websocket client. +# start typing. +``` diff --git a/_examples/websocket/basic/browser/index.html b/_examples/websocket/basic/browser/index.html index 2f846405..b20a90e3 100644 --- a/_examples/websocket/basic/browser/index.html +++ b/_examples/websocket/basic/browser/index.html @@ -10,7 +10,7 @@ However, `neffos.(min.)js` is a NPM package too so alternatively, you can use it as dependency on your package.json and all nodejs-npm tooling become available: see the "browserify" example for more--> - +