- commit
- 0b2607c0e504345f5ce7eac688bdbcef30453e56
- parent
- 8c2dc7ee8dce47134d7ba3b827d658298309eb65
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-05-03 19:04
use consistent message format
Diffstat
| M | static/index.js | 19 | ++++++++----------- |
1 files changed, 8 insertions, 11 deletions
diff --git a/static/index.js b/static/index.js
@@ -38,23 +38,20 @@ el.addEventListener('input', function() {
38 38 signal.listen(room, function(msg) {
39 39 if (msg.sender === id) {
40 40 return
41 -1 } else if (msg.changes) {
42 -1 applyChanges(msg.changes);
43 -1 } else if (msg.request === 'text') {
44 -1 signal.post(room, {sender: id, text: el.value});
45 -1 } else if (msg.text && !el.value) {
46 -1 setText(msg.text, 0, 0);
-1 41 } else if (msg.type === 'changes') {
-1 42 applyChanges(msg.data);
-1 43 } else if (msg.type === 'request') {
-1 44 signal.post(room, {sender: id, type: 'text', data: el.value});
-1 45 } else if (msg.type === 'text' && !el.text) {
-1 46 setText(msg.data, 0, 0);
47 47 }
48 48 });
49 49
50 50 setInterval(function() {
51 51 if (localChanges.length) {
52 -1 signal.post(room, {
53 -1 sender: id,
54 -1 changes: localChanges,
55 -1 });
-1 52 signal.post(room, {sender: id, type: 'changes', data: localChanges});
56 53 localChanges = [];
57 54 }
58 55 }, 500);
59 56
60 -1 signal.post(room, {sender: id, request: 'text'});
-1 57 signal.post(room, {sender: id, type: 'request'});