mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 02:17:05 +00:00
_examples/websocket/basic: add a nodejs client and provide a README.md on how to run the websocket clients and the server
Former-commit-id: a98a80996d7d95fa947e72c71803407682229fa7
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
# Browserify example
|
||||
|
||||
```sh
|
||||
$ npm install --only=dev # install browserify from the devDependencies.
|
||||
$ npm run-script build # browserify and minify the `app.js` into `bundle.js`.
|
||||
$ cd ../ && go run server.go # start the neffos server.
|
||||
```
|
||||
|
||||
> make sure that you have [golang](https://golang.org/dl) installed to run and edit the neffos (server-side).
|
||||
|
||||
That's all, now navigate to <http://localhost:8080/browserify>.
|
||||
@@ -6,6 +6,7 @@ var port = document.location.port ? ":" + document.location.port : "";
|
||||
var wsURL = scheme + "://" + document.location.hostname + port + "/echo";
|
||||
|
||||
var outputTxt = document.getElementById("output");
|
||||
|
||||
function addMessage(msg) {
|
||||
outputTxt.innerHTML += msg + "\n";
|
||||
}
|
||||
@@ -16,6 +17,8 @@ function handleError(reason) {
|
||||
}
|
||||
|
||||
function handleNamespaceConnectedConn(nsConn) {
|
||||
nsConn.emit("chat", "Hello from browser(ify) client-side!");
|
||||
|
||||
const inputTxt = document.getElementById("input");
|
||||
const sendBtn = document.getElementById("sendBtn");
|
||||
|
||||
@@ -50,6 +53,7 @@ async function runExample() {
|
||||
// and put the `handleNamespaceConnectedConn` inside `_OnNamespaceConnected` callback instead.
|
||||
// const nsConn = await conn.connect("default");
|
||||
// handleNamespaceConnectedConn(nsConn);
|
||||
// nsConn.emit(...); handleNamespaceConnectedConn(nsConn);
|
||||
conn.connect("default");
|
||||
|
||||
} catch (err) {
|
||||
@@ -57,5 +61,4 @@ async function runExample() {
|
||||
}
|
||||
}
|
||||
|
||||
runExample();
|
||||
|
||||
runExample();
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user