|
@@ 625-643 (lines=19) @@
|
| 622 |
|
connection_id = in_message[VarNames.CONNECTION_ID] |
| 623 |
|
self_status = self.sync_redis.shget(connection_id, self.id) |
| 624 |
|
if self_status == WebRtcRedisStates.RESPONDED: |
| 625 |
|
self.sync_redis.hset(connection_id, self.id, WebRtcRedisStates.READY) |
| 626 |
|
channel_status = self.sync_redis.shgetall(connection_id) |
| 627 |
|
del channel_status[self.id] |
| 628 |
|
message = { |
| 629 |
|
VarNames.EVENT: Actions.ACCEPT_CALL, |
| 630 |
|
VarNames.USER_ID: self.user_id, |
| 631 |
|
VarNames.CONNECTION_ID: connection_id, |
| 632 |
|
VarNames.WEBRTC_OPPONENT_ID: self.id, |
| 633 |
|
VarNames.HANDLER_NAME: HandlerNames.WEBRTC_TRANSFER, |
| 634 |
|
} |
| 635 |
|
for key in channel_status: |
| 636 |
|
if channel_status[key] != WebRtcRedisStates.CLOSED: |
| 637 |
|
self.publish(message, key) |
| 638 |
|
else: |
| 639 |
|
raise ValidationError("Invalid channel status") |
| 640 |
|
|
| 641 |
|
def offer_webrtc_connection(self, in_message): |
| 642 |
|
room_id = in_message[VarNames.CHANNEL] |
| 643 |
|
content = in_message.get(VarNames.CONTENT) |
| 644 |
|
qued_id = in_message[VarNames.WEBRTC_QUED_ID] |
| 645 |
|
connection_id = id_generator(RedisPrefix.CONNECTION_ID_LENGTH) |
| 646 |
|
# use list because sets dont have 1st element which is offerer |
|
@@ 536-553 (lines=18) @@
|
| 533 |
|
self.do_db(message_db.save) |
| 534 |
|
db_images = self.save_images(raw_imgs, message_db.id) |
| 535 |
|
prepared_message = self.create_send_message( |
| 536 |
|
message_db, |
| 537 |
|
Actions.PRINT_MESSAGE, |
| 538 |
|
self.prepare_img(db_images, message_db.id) |
| 539 |
|
) |
| 540 |
|
self.publish(prepared_message, channel) |
| 541 |
|
|
| 542 |
|
def close_file_connection(self, in_message): |
| 543 |
|
connection_id = in_message[VarNames.CONNECTION_ID] |
| 544 |
|
self_channel_status = self.sync_redis.shget(connection_id, self.id) |
| 545 |
|
if not self_channel_status: |
| 546 |
|
raise Exception("Access Denied") |
| 547 |
|
if self_channel_status != WebRtcRedisStates.CLOSED: |
| 548 |
|
sender_id = self.sync_redis.shget(WEBRTC_CONNECTION, connection_id) |
| 549 |
|
if sender_id == self.id: |
| 550 |
|
self.close_file_sender(connection_id) |
| 551 |
|
else: |
| 552 |
|
self.close_file_receiver(connection_id, in_message, sender_id) |
| 553 |
|
self.async_redis_publisher.hset(connection_id, self.id, WebRtcRedisStates.CLOSED) |
| 554 |
|
|
| 555 |
|
def close_call_connection(self, in_message): |
| 556 |
|
connection_id = in_message[VarNames.CONNECTION_ID] |