Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmota committed Jun 30, 2017
1 parent a96fa5a commit 0386bd1
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 8 deletions.
61 changes: 57 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,49 @@

> stream stuff
- Nothing is stored; only streamed.
- Originally created this to quickly share data and files between devices.
- Path names map to channels.
- Anyone in the same channel can view what's streamed.

[https://streamhut.net](https://streamhut.net)

## Usage

Start server

```bash
npm start
$ npm start

Listening on port 8956
```

Build client
Start server on specific port

```bash
npm run build
$ PORT=8080 npm start

Listening on port 8080
```

## Development

Watch and build client scripts

```bash
$ npm run watch
```

Build client scripts

```bash
$ npm run build
```

## CLI

```bash
npm install -g streamhut
$ npm install -g streamhut
```

```bash
Expand Down Expand Up @@ -70,6 +95,34 @@ $ streamhut -help
-f, --file <filepath> file to send
```

Listening on a channel

```bash
$ streamhut listen -h streamhut.net -c yo
connected to wss://streamhut.net/yo

received Fri Jun 30 2017 14:40:14 GMT-0700 (PDT):

hello

```

Posting text data to a channel

```bash
$ streamhut post -h streamhut.net -c yo -t "hello"
posting data to wss://streamhut.net/yo:

hello

```

## Test

```bash
npm test
```

## License

MIT
18 changes: 14 additions & 4 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ const packageJson = require('./package.json')

const art = fs.readFileSync('./hut.txt', 'utf8')

console.log(art)
if (process.argv.indexOf('--help') > -1 &&
process.argv.length === 3) {
console.log(art)
}

program
.version(packageJson.version)
Expand All @@ -36,7 +39,7 @@ program
} = program

if (!host || !channel) {
program.help()
showHelp()
return false
}

Expand All @@ -54,15 +57,22 @@ program
text,
file
})
} else {
showHelp()
}
})
.parse(process.argv)

if (!program.args.length) {
program.help()
showHelp()
return false
}

function showHelp() {
console.log(art)
program.help()
}

function listen(props) {
const url = constructWebsocketUrl(props)
const ws = new WebSocket(url)
Expand Down Expand Up @@ -101,7 +111,7 @@ function post(props) {
ws.binaryType = 'arraybuffer'

ws.on('open', () => {
console.log(`posting data to ${url}:\n\n`, text)
console.log(`posting data to ${url}:\n\n${text}\n`)
const mime = 'text/plain'
const arrayBuffer = str2ab(text)
const abWithMime = arrayBufferWithMime(arrayBuffer, mime)
Expand Down

0 comments on commit 0386bd1

Please sign in to comment.