|
@@ 625-643 (lines=19) @@
|
| 622 |
|
# else: |
| 623 |
|
# raise ValidationError("Invalid channel status") |
| 624 |
|
|
| 625 |
|
def accept_call(self, in_message): |
| 626 |
|
connection_id = in_message[VarNames.CONNECTION_ID] |
| 627 |
|
self_status = self.sync_redis.shget(connection_id, self.id) |
| 628 |
|
if self_status == WebRtcRedisStates.RESPONDED: |
| 629 |
|
self.sync_redis.hset(connection_id, self.id, WebRtcRedisStates.READY) |
| 630 |
|
channel_status = self.sync_redis.shgetall(connection_id) |
| 631 |
|
del channel_status[self.id] |
| 632 |
|
message = { |
| 633 |
|
VarNames.EVENT: Actions.ACCEPT_CALL, |
| 634 |
|
VarNames.USER_ID: self.user_id, |
| 635 |
|
VarNames.CONNECTION_ID: connection_id, |
| 636 |
|
VarNames.WEBRTC_OPPONENT_ID: self.id, |
| 637 |
|
VarNames.HANDLER_NAME: HandlerNames.WEBRTC_TRANSFER, |
| 638 |
|
} |
| 639 |
|
for key in channel_status: |
| 640 |
|
if channel_status[key] != WebRtcRedisStates.CLOSED: |
| 641 |
|
self.publish(message, key) |
| 642 |
|
else: |
| 643 |
|
raise ValidationError("Invalid channel status") |
| 644 |
|
|
| 645 |
|
def offer_webrtc_connection(self, in_message): |
| 646 |
|
room_id = in_message[VarNames.CHANNEL] |
|
@@ 536-553 (lines=18) @@
|
| 533 |
|
self.close_receiver(connection_id, in_message, sender_id) |
| 534 |
|
self.async_redis_publisher.hset(connection_id, self.id, WebRtcRedisStates.CLOSED) |
| 535 |
|
|
| 536 |
|
def close_call_connection(self, in_message): |
| 537 |
|
connection_id = in_message[VarNames.CONNECTION_ID] |
| 538 |
|
conn_users = self.sync_redis.shgetall(connection_id) |
| 539 |
|
if conn_users[self.id] in [WebRtcRedisStates.READY, WebRtcRedisStates.RESPONDED]: |
| 540 |
|
self.async_redis_publisher.hset(connection_id, self.id, WebRtcRedisStates.CLOSED) |
| 541 |
|
del conn_users[self.id] |
| 542 |
|
message = { |
| 543 |
|
VarNames.EVENT: Actions.CLOSE_CALL_CONNECTION, |
| 544 |
|
VarNames.CONNECTION_ID: connection_id, |
| 545 |
|
VarNames.USER_ID: self.user_id, |
| 546 |
|
VarNames.WEBRTC_OPPONENT_ID: self.id, |
| 547 |
|
VarNames.HANDLER_NAME: HandlerNames.PEER_CONNECTION, |
| 548 |
|
} |
| 549 |
|
for user in conn_users: |
| 550 |
|
if conn_users[user] != WebRtcRedisStates.CLOSED: |
| 551 |
|
self.publish(message, user) |
| 552 |
|
else: |
| 553 |
|
raise ValidationError("Invalid channel status.") |
| 554 |
|
|
| 555 |
|
def cancel_call_connection(self, in_message): |
| 556 |
|
connection_id = in_message[VarNames.CONNECTION_ID] |