mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 09:23:13 +01:00
ws for progress bar
This commit is contained in:
parent
708cf1b3da
commit
b4e8e3d9dc
@ -5,7 +5,6 @@ import Router from 'react-router';
|
||||
import DropdownButton from 'react-bootstrap/lib/DropdownButton';
|
||||
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
|
||||
import MenuItem from 'react-bootstrap/lib/MenuItem';
|
||||
|
||||
import Nav from 'react-bootstrap/lib/Nav';
|
||||
|
||||
import NotificationActions from '../actions/notification_actions';
|
||||
@ -14,6 +13,8 @@ import NotificationStore from '../stores/notification_store';
|
||||
import { mergeOptions } from '../utils/general_utils';
|
||||
import { getLangText } from '../utils/lang_utils';
|
||||
|
||||
import client from './websocket_test';
|
||||
|
||||
let Link = Router.Link;
|
||||
|
||||
|
||||
|
31
js/components/websocket_test.js
Normal file
31
js/components/websocket_test.js
Normal file
@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
let client = new WebSocket('ws://localhost.com:8000/ws/foobar?subscribe-broadcast&publish-broadcast&echo');
|
||||
|
||||
client.onerror = function() {
|
||||
console.log('Connection Error');
|
||||
};
|
||||
|
||||
client.onopen = function() {
|
||||
console.log('WebSocket Client Connected');
|
||||
function sendNumber() {
|
||||
if (client.readyState === client.OPEN) {
|
||||
var number = Math.round(Math.random() * 0xFFFFFF);
|
||||
client.send(number.toString());
|
||||
setTimeout(sendNumber, 5000);
|
||||
}
|
||||
}
|
||||
//sendNumber();
|
||||
};
|
||||
|
||||
client.onclose = function() {
|
||||
console.log('echo-protocol Client Closed');
|
||||
};
|
||||
|
||||
client.onmessage = function(e) {
|
||||
if (typeof e.data === 'string' && e.data !== "--heartbeat--") {
|
||||
console.log("Received: '" + e.data + "'");
|
||||
}
|
||||
};
|
||||
|
||||
export default client;
|
@ -86,6 +86,8 @@
|
||||
"vinyl-buffer": "^1.0.0",
|
||||
"vinyl-source-stream": "^1.1.0",
|
||||
"watchify": "^3.1.2",
|
||||
"websocket": "^1.0.22",
|
||||
"ws": "^0.8.0",
|
||||
"yargs": "^3.10.0"
|
||||
},
|
||||
"jest": {
|
||||
|
Loading…
Reference in New Issue
Block a user