-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add hooks for m.call.* #201
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -254,6 +254,76 @@ def send_message_event(self, room_id, event_type, content, txn_id=None, | |
params["ts"] = timestamp | ||
return self._send("PUT", path, content, query_params=params) | ||
|
||
def send_call_invite(self, room_id, call_id, sdp, version, lifetime, | ||
msgtype="m.call.invite", timestamp=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"""Perform PUT /rooms/$room_id/send/m.room.call.invite | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this is actually Yep, you've got it right in actual method; just need to fixup docstring. |
||
|
||
Args: | ||
room_id (str): The room ID to send the event in. | ||
call_id (str): Call identifier string. | ||
sdp (dict): Session Description Protocol dict. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From spec, looks like sdp is a string rather than a dict? |
||
version (int): The version of the VoIP specification this messages adheres to. | ||
lifetime (int): The time in milliseconds that the invite is valid for. | ||
timestamp (int): Set origin_server_ts (For application services only) | ||
""" | ||
return self.send_message_event( | ||
room_id, "m.call.invite", | ||
self.get_call_invite_content(call_id, sdp, version, lifetime), | ||
timestamp=timestamp | ||
) | ||
|
||
def send_call_answer(self, room_id, call_id, sdp, version, lifetime, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Many comments from above appear to apply to all api methods. |
||
msgtype="m.call.answer", timestamp=None): | ||
"""Perform PUT /rooms/$room_id/send/m.room.call.answer | ||
|
||
Args: | ||
room_id (str): The room ID to send the event in. | ||
call_id (str): Call identifier string. | ||
sdp (dict): Session Description Protocol dict. | ||
version (int): The version of the VoIP specification this messages adheres to. | ||
lifetime (int): The time in milliseconds that the answer is valid for. | ||
timestamp (int): Set origin_server_ts (For application services only) | ||
""" | ||
return self.send_message_event( | ||
room_id, "m.call.answer", | ||
self.get_call_answer_content(call_id, sdp, lifetime, version), | ||
timestamp=timestamp | ||
) | ||
|
||
def send_call_candidates(self, room_id, call_id, candidates, version, | ||
msgtype="m.call.candidates", timestamp=None): | ||
"""Perform PUT /rooms/$room_id/send/m.room.call.candidates | ||
|
||
Args: | ||
room_id (str): The room ID to send the event in. | ||
call_id (str): The call identifier string. | ||
candidates (array of dicts): The candidates to send: | ||
each array element contains 'candidate', 'sdpMLineIndex', and 'sdpMid' | ||
version (int): The version of the VoIP specification this messages adheres to. | ||
timestamp (int): Set origin_server_ts (For application services only) | ||
""" | ||
return self.send_message_event( | ||
room_id, "m.call.candidates", | ||
self.get_call_candidates_content(call_id, candidates, version), | ||
timestamp=timestamp | ||
) | ||
|
||
def send_call_hangup(self, room_id, call_id, version, | ||
msgtype="m.call.hangup", timestamp=None): | ||
"""Perform PUT /rooms/$room_id/send/m.room.call.hangup | ||
|
||
Args: | ||
room_id (str): The room ID to send the event in. | ||
call_id (str): The call identifier string. | ||
version (int): The version of the VoIP specification this messages adheres to. | ||
timestamp (int): Set origin_server_ts (For application services only) | ||
""" | ||
return self.send_message_event( | ||
room_id, "m.call.hangup", | ||
self.get_call_hangup_content(call_id, version), | ||
timestamp=timestamp | ||
) | ||
|
||
def redact_event(self, room_id, event_id, reason=None, txn_id=None, timestamp=None): | ||
"""Perform PUT /rooms/$room_id/redact/$event_id/$txn_id/ | ||
|
||
|
@@ -621,6 +691,41 @@ def get_text_body(self, text, msgtype="m.text"): | |
"body": text | ||
} | ||
|
||
def get_call_invite_content(self, call_id, sdp, version, lifetime, types="offer"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this dictionary constructed under a separate method rather than just in the method body of Stylistically, if kept as a separate method, |
||
return{ | ||
"call_id": call_id, | ||
"lifetime": lifetime, | ||
"offer": { | ||
"spd": sdp, | ||
"type": types | ||
}, | ||
"version": version | ||
} | ||
|
||
def get_call_answer_content(self, call_id, sdp, lifetime, version, types="answer"): | ||
return{ | ||
"call_id": call_id, | ||
"lifetime": lifetime, | ||
"answer": { | ||
"sdp": sdp, | ||
"type": types | ||
}, | ||
"version": version | ||
} | ||
|
||
def get_call_candidates_content(self, call_id, candidates, version): | ||
return{ | ||
"call_id": call_id, | ||
"candidates": candidates, | ||
"version": version | ||
} | ||
|
||
def get_call_hangup_content(self, call_id, version): | ||
return{ | ||
"call_id": call_id, | ||
"version": version | ||
} | ||
|
||
def get_emote_body(self, text): | ||
return { | ||
"msgtype": "m.emote", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,6 +222,50 @@ def send_audio(self, url, name, **audioinfo): | |
return self.client.api.send_content(self.room_id, url, name, "m.audio", | ||
extra_information=audioinfo) | ||
|
||
def send_call_invite(self, call_id, sdp, version, lifetime): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These don't offer any additional abstraction over methods defined in api class. Until we have a reason to put methods here that make interacting with the api methods easier, probably just delete these methods. |
||
""" Send a call invite event to the room. | ||
|
||
Args: | ||
call_id (str): Random call identifier string. | ||
sdp (dict): Invite Session Description Protocol dict. | ||
version (int): The version of the VoIP specification this message adheres to. | ||
lifetime (int): The time in milliseconds that the invite is valid for. | ||
""" | ||
return self.client.api.send_call_invite(self.room_id, call_id, | ||
sdp, version, lifetime) | ||
|
||
def send_call_answer(self, call_id, sdp, version, lifetime): | ||
""" Send a call answer event to the room. | ||
|
||
Args: | ||
call_id (str): The call identifier string. | ||
sdp (dict): Session Description Protocol dict. | ||
version (int): The version of the VoIP specification this messages adheres to. | ||
lifetime (int): The time in milliseconds that the answer is valid for. | ||
""" | ||
return self.client.api.send_call_answer(self.room_id, call_id, | ||
sdp, version, lifetime) | ||
|
||
def send_call_candidates(self, call_id, candidates, version): | ||
""" Send a call candidates event to the room. | ||
|
||
Args: | ||
call_id (str): The call identifier string. | ||
candidates (dict): The candidates to send | ||
version (int): The version of the VoIP specification this messages adheres to. | ||
""" | ||
return self.client.api.send_call_candidates(self.room_id, call_id, | ||
candidates, version) | ||
|
||
def send_call_hangup(self, call_id, version): | ||
""" Send a call hangup event to the room. | ||
|
||
Args: | ||
call_id (str): The call identifier string. | ||
version (int): The version of the VoIP specification this messages adheres to. | ||
""" | ||
return self.client.api.send_call_hangup(self.room_id, call_id, version) | ||
|
||
def redact_message(self, event_id, reason=None): | ||
""" Redacts the message with specified event_id in the room. | ||
See https://matrix.org/docs/spec/r0.0.1/client_server.html#id112 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version
should probably be kwarg with default value of0
.