Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rainabba/nwk-socket.io
Node-WebKit running a Hapi server, hosting Socket.io to demonstrate how NWK must be configured for this.
https://github.com/rainabba/nwk-socket.io
Last synced: 26 days ago
JSON representation
Node-WebKit running a Hapi server, hosting Socket.io to demonstrate how NWK must be configured for this.
- Host: GitHub
- URL: https://github.com/rainabba/nwk-socket.io
- Owner: rainabba
- Created: 2014-11-07T14:42:30.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-04-10T03:59:47.000Z (over 9 years ago)
- Last Synced: 2024-04-23T22:09:01.902Z (7 months ago)
- Language: JavaScript
- Size: 146 KB
- Stars: 9
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nwk-socket.io
Node-WebKit running a Hapi server, hosting Socket.io to demonstrate how NWK must be configured for this.
The key here is in package.json. Look at:
```
...
"main" : "http://github.rainabba.me",
"node-main": "index.js",
"node-local": "rainabba.me",
...
```"main" is what nwk will load into the "browser window". In my case, this is a public page that will try to load up socket.io from localhost:8883 which would be provided by this app if it were running (you can run directly as a node app for testing and to have acccess to the console). "node-main" tells nwk where the actual entry point is for the node app that will run the Hapi server that hosts socket.io. "node-local" may be required to deal with some cors issues, but I'm not clear on this even after getting things working.
In reality, this app isn't even about socket.io though it provides an example of how this can be done, but really it shows what I thought of as the most obvious use of nwk from the instant I heard of it; how to run a node-app locally, without the user needing to install node, and then displaying a real website (be it a remote OR one running in that node app).
The purpose of this approach is to be able to host a public site that will try to connect to a socket.io on localhost:8883 and if it's there, use that connection to communicate with an app running on the desktop with all the power of libuv; which I use to launch and manage a native app. This gives me one public web UI that can deal with any native platform through the abstraction provided by the locally running socket.io server. This way I can have a seperate nwk package for each platform and the the UI is consistent and reusable while the native bits can be anything needed for that platform.
# Installation
**node app only but can be packaged and run directly as a node-webkit app using [Node-WebKit](https://github.com/rogerwang/node-webkit)**```
git clone https://github.com/rainabba/nwk-socket.io
cd nwk-socket.io
npm install
node index.js
```Then visit http://github.rainabba.me