作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将第一个加入 session 的用户设置为主持人,并且我正在使用 twilio-python doc来帮助我,但我没有看到任何有关此的信息。
第一个参与者应该是主持人,以便将另一个参与者静音、踢等,但说实话,我不知道这是否真的需要,所以我愿意“不需要主持人”。
此外,我想知道与 token 相关的名称是否在参与者中,以便使用此名称而不是 SID 来检索它。 (在文档中没有看到任何内容)
这里是服务器端代码:
@app.route('/call', methods=['GET', 'POST'])
def call():
resp = twilio.twiml.Response()
from_value = request.values.get('From')
to = request.values.get('To')
conferenceName = request.values.get('conferenceName')
account_sid = os.environ.get("ACCOUNT_SID", ACCOUNT_SID)
auth_token = os.environ.get("AUTH_TOKEN", AUTH_TOKEN)
app_sid = os.environ.get("APP_SID", APP_SID)
clientTwilio = TwilioRestClient(account_sid, auth_token)
elif to.startswith("conference:"):
# allows to user conference call
# client -> conference
conferencesList = client.conferences.list(friendly_name=conferenceName)
#there's no conference with the conferenceName so the first person should be the moderator and join it
if len(conferencesList) == 0
#do somestuff to set a moderator [...]
resp.dial(callerId=from_value).conference(to[11:])
else:
#there's already a conference just join it
resp.dial(callerId=from_value).conference(to[11:])
对于与我想用来检索参与者的 token /客户端相关的“名称”:
//http://foo.herokuapp.com/token?client=someName"
self.phone = [[TCDevice alloc] initWithCapabilityToken:token delegate:self];
NSDictionary *params = @{@"To": @"conference:foo"};
self.connection = [self.phone connect:params delegate:self];
[self closeNoddersView:nil];
//the user is connected as participant in the conference, is it possible to retrieve it with the "someName" ? (server side route which take a "someName" in param)
有什么线索吗? :/
最佳答案
我找到了使用 client:name 的解决方法,并且不需要主持人
a conference contains a list of participant
a participant is related to a specific call
a call contains the information in the to and from_: client:name
@app.route('/conference_kick', methods=['GET', 'POST'])
def conference():
client = TwilioRestClient(account_sid, auth_token)
conferenceName = request.values.get('conferenceName')
participantName = request.values.get('participantName')
index = 0
call = ""
# A list of conference objects
conferencesList = client.conferences.list(status="in-progress",friendly_name=conferenceName)
if len(conferencesList) == 1:
if conferencesList[0].participants:
participants = conferencesList[0].participants.list()
while index < len(participants):
call = client.calls.get(participants[index].call_sid)
array = call.from_.split(':')
if participantName == array[1]:
participants[index].kick()
return json.dumps({'code' : 200, 'success':1, 'message':participantName+' kicked'})
index += 1
return json.dumps({'code' : 101, 'success':0, 'message':participantName+' not found'})
else:
return json.dumps({'code' : 102, 'success':0, 'message':'no participants'})
else:
return json.dumps({'code' : 103, 'success':0, 'message':'no conference'})
关于python - Twilio session 主持人和参与者姓名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35033259/
在我的课上,我有以下声明: class OCLState { //Irrelevant stuff involving OpenCL contexts and command queues a
我是一名优秀的程序员,十分优秀!