Ramesh-vani commited on
Commit
84294e1
·
verified ·
1 Parent(s): c2a0cab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +83 -0
app.py CHANGED
@@ -466,6 +466,87 @@ async def handle_user_input(websocket,key, process, connected):
466
  'color':event["color"]
467
  }
468
  websockets.broadcast(connected, json.dumps(event))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
469
 
470
  else:
471
  # First player starts a new game.
@@ -776,6 +857,8 @@ async def exe(websocket,connected,key):
776
 
777
  }
778
  websockets.broadcast(connected, json.dumps(event))
 
 
779
 
780
  else:
781
  # First player starts a new game.
 
466
  'color':event["color"]
467
  }
468
  websockets.broadcast(connected, json.dumps(event))
469
+ elif event["command"]["type"]=="cursor":
470
+
471
+ event = {
472
+ "type": "cursor",
473
+ 'offset': event["offset"],
474
+ 'userid': event["userid"],
475
+ 'userlabel': event["userlabel"],
476
+ 'usercolor': event["usercolor"],
477
+ 'fileName':event["fileName"],
478
+
479
+ }
480
+ websockets.broadcast(connected, json.dumps(event))
481
+ elif event["command"]["type"]=="select":
482
+
483
+ event = {
484
+ "type": "select",
485
+ 'id': event["id"],
486
+ 'startOffset': event["startOffset"],
487
+ 'endOffset': event["endOffset"],
488
+ 'userid': event["userid"],
489
+ 'userlabel': event["userlabel"],
490
+ 'usercolor': event["usercolor"],
491
+ 'fileName':event["fileName"],
492
+
493
+ }
494
+ websockets.broadcast(connected, json.dumps(event))
495
+ elif event["command"]["type"]=="addselection":
496
+
497
+ event = {
498
+ "type": "addselection",
499
+
500
+ 'userid': event["userid"],
501
+ 'userlabel': event["userlabel"],
502
+ 'usercolor': event["usercolor"],
503
+
504
+
505
+ }
506
+ websockets.broadcast(connected, json.dumps(event))
507
+ elif event["command"]["type"]=="insert":
508
+
509
+ event = {
510
+ "type": "insert",
511
+ 'index': event["index"],
512
+ 'text': event["text"],
513
+ 'userid': event["userid"],
514
+ 'userlabel': event["userlabel"],
515
+ 'usercolor': event["usercolor"],
516
+ 'fileName':event["fileName"],
517
+
518
+ }
519
+ websockets.broadcast(connected, json.dumps(event))
520
+ elif event["command"]["type"]=="replace":
521
+
522
+ event = {
523
+ "type": "replace",
524
+ 'index': event["index"],
525
+ 'length': event["length"],
526
+ 'text': event["text"],
527
+ 'userid': event["userid"],
528
+ 'userlabel': event["userlabel"],
529
+ 'usercolor': event["usercolor"],
530
+ 'fileName':event["fileName"],
531
+
532
+ }
533
+ websockets.broadcast(connected, json.dumps(event))
534
+ elif event["command"]["type"]=="edelelte":
535
+
536
+ event = {
537
+ "type": "edelelte",
538
+ 'index': event["index"],
539
+ 'length': event["length"],
540
+ 'userid': event["userid"],
541
+ 'userlabel': event["userlabel"],
542
+ 'usercolor': event["usercolor"],
543
+ 'fileName':event["fileName"],
544
+
545
+
546
+ }
547
+ websockets.broadcast(connected, json.dumps(event))
548
+ elif event["command"]["type"]=="keep-alive":
549
+ pass
550
 
551
  else:
552
  # First player starts a new game.
 
857
 
858
  }
859
  websockets.broadcast(connected, json.dumps(event))
860
+ elif event["command"]["type"]=="keep-alive":
861
+ pass
862
 
863
  else:
864
  # First player starts a new game.