socket.me
Version:
Fast Strong-typed WebSockets
44 lines (32 loc) • 996 B
HTML
<html lang="en">
<head>
<title></title>
<meta charset="utf-8">
</head>
<body></body>
<script src="http://localhost:3500/socket.me"></script>
<script>
const ws = mio('localhost:3500');
//---]>
ws.onConnect(() => {
console.log('[open] Соединение установлено');
//---]>
// ok
ws.emit('object', { id: 1, name: 'test', tags: [1,2] });
ws.emit('array', [1, 'test']);
ws.emit('primitive', 1);
//---]>
// bad
ws.emit('object');
ws.emit('object', { name: 'test' });
ws.emit('object', { id: '1', name: 'test', tags: [] });
ws.emit('object', { id: 1, name: 'test', x: 0 });
ws.emit('array');
ws.emit('array', ['test']);
ws.emit('array', ['1', 'test']);
ws.emit('primitive');
ws.emit('primitive', '1');
});
</script>
</html>