-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathtest.js
More file actions
30 lines (25 loc) · 679 Bytes
/
test.js
File metadata and controls
30 lines (25 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var server = require('./')()
var port = 8080
server.listen(port)
var websocketStream = require('websocket-stream')
var WebSocket = require('ws')
var ws = new WebSocket('ws://localhost:8080')
var wsStream = websocketStream(ws)
var duplexEmitter = require('duplex-emitter')
var client = duplexEmitter(wsStream)
client.on('id', function(id) {
console.log('got id:', id)
})
client.on('settings', function(settings) {
console.log('got settings:', settings)
})
ws.on('open', function() {
client.emit('created')
})
client.on('chunk', function(chunk) {
console.log('got initial chunk')
})
client.on('noMoreChunks', function() {
console.log('all done')
process.exit()
})