Fixed negotiation
This commit is contained in:
parent
afdf856f2b
commit
ce012e253c
@ -233,10 +233,20 @@ class WebRTCSignalingHandlers:
|
|||||||
# Determine deterministic offerer to avoid glare/collision:
|
# Determine deterministic offerer to avoid glare/collision:
|
||||||
# the peer with the lexicographically smaller session ID will create the offer.
|
# the peer with the lexicographically smaller session ID will create the offer.
|
||||||
try:
|
try:
|
||||||
|
# Prefer bots to be the offerer when pairing a bot with a human.
|
||||||
|
# If one side is a bot and the other isn't, the bot will create the offer.
|
||||||
|
if getattr(session, "bot_instance_id", None) and not getattr(peer_session, "bot_instance_id", None):
|
||||||
|
session_is_offer = True
|
||||||
|
elif getattr(peer_session, "bot_instance_id", None) and not getattr(session, "bot_instance_id", None):
|
||||||
|
session_is_offer = False
|
||||||
|
else:
|
||||||
|
# Deterministic fallback: lexicographic session id
|
||||||
session_is_offer = session.id < peer_session.id
|
session_is_offer = session.id < peer_session.id
|
||||||
|
|
||||||
# Notify existing peer about new peer
|
# Notify existing peer about new peer
|
||||||
peer_should_create_offer = peer_session.id < session.id
|
peer_should_create_offer = peer_session.id < session.id if not (
|
||||||
|
getattr(session, "bot_instance_id", None) or getattr(peer_session, "bot_instance_id", None)
|
||||||
|
) else (True if getattr(peer_session, "bot_instance_id", None) and not getattr(session, "bot_instance_id", None) else False)
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{session.getName()} -> {peer_session.getName()}:addPeer("
|
f"{session.getName()} -> {peer_session.getName()}:addPeer("
|
||||||
f"{session.getName()}, {lobby.getName()}, should_create_offer={peer_should_create_offer}, "
|
f"{session.getName()}, {lobby.getName()}, should_create_offer={peer_should_create_offer}, "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user