1
0
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:
diminator 2015-10-06 10:03:00 +02:00
parent 708cf1b3da
commit b4e8e3d9dc
3 changed files with 35 additions and 1 deletions

View File

@ -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;

View 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;

View File

@ -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": {