def requestVideoCallWithUsername(request): """ This method is called when a user request a video conference. Example: username=ddmbr&callToUsername=test """ if request.method == 'POST': caller = request.POST['username'] caller_uid = user.getIdByUsername(caller) reviever = request.POST['callToUsername'] reviever_uid = user.getIdByUsername(reciever) # # check the caller's and reciever's languages reciever_lang = user.getLanguageByID(reciever_uid) caller_lang = user.getLanguageByID(caller_uid) # # find a proper translator user.callTranslator(caller_lang, reciever_lang) # # call the reciever logging.info("%s want to start a conference with %s", caller, reciever) user.startCall(caller_uid, reciever_uid) # # Try to send a notification callInfo = getMyInfo( username ) data = {"callType":"videoCall", "callContact": callInfo } user.sendPushMsg(reciever_uid) # # get he's tokbox session id session_id = user.getVideoSessionById(caller_uid) # # generate a corresponding token token = opentok_sdk.generate_token(session_id) to_json = {'requestType':'videoCall', 'message':'accept', 'sessionId':session_id, 'token':token} response = HttpResponse(simplejson.dumps(to_json), mimetype='application/json') else: response = HttpResponse("Error!") if request.META['HTTP_USER_AGENT'].find("iPhone") == -1: response['Access-Control-Allow-Origin']='*' return response
def callInterpreter(request): if request.method=='POST': username = request.POST['username'] uid - user.getIdByUsername(username) lang_1 = request.POST['myLanguage'] lang_2 = request.POST['targetLanguage'] user.requireTranslator(uid, lang_1, lang_2) # # get he's tokbox session id session_id = user.getVideoSessionById(caller_uid) # # generate a corresponding token token = opentok_sdk.generate_token(session_id) to_json = {'requestType':'interpreterVideoCall', 'message':'accept', 'sessionId':session_id, 'token':token} response = HttpResponse(simplejson.dumps(to_json), mimetype='application/json') return response