parameters: (request)
return_statement: return JsonResponse(dict(cmds=[cmd]))
docstring: Endpoint for Android devices registering with this server
docstring_summary: Endpoint for Android devices registering with this server
docstring_tokens: Endpoint for Android devices registering with this server
function: def register(request):
      """
      Endpoint for Android devices registering with this server
      """
      if request.method != "POST":
          return HttpResponse(status=500, content=_("POST Required"))
  
      client_payload = json.loads(force_str(request.body))
      cmds = client_payload["cmds"]
  
      try:
          # look up a channel with that id
          channel = Channel.get_or_create_android(cmds[0], cmds[1])
          cmd = dict(
              cmd="reg", relayer_claim_code=channel.claim_code, relayer_secret=channel.secret, relayer_id=channel.id
          )
      except UnsupportedAndroidChannelError:
          cmd = dict(cmd="reg", relayer_claim_code="*********", relayer_secret="0" * 64, relayer_id=-1)
  
      return JsonResponse(dict(cmds=[cmd]))
function_tokens: def register ( request ) : if request . method != "POST" : return HttpResponse ( status = 500 , content = _ ( "POST Required" ) ) client_payload = json . loads ( force_str ( request . body ) ) cmds = client_payload [ "cmds" ] try : # look up a channel with that id channel = Channel . get_or_create_android ( cmds [ 0 ] , cmds [ 1 ] ) cmd = dict ( cmd = "reg" , relayer_claim_code = channel . claim_code , relayer_secret = channel . secret , relayer_id = channel . id ) except UnsupportedAndroidChannelError : cmd = dict ( cmd = "reg" , relayer_claim_code = "*********" , relayer_secret = "0" * 64 , relayer_id = - 1 ) return JsonResponse ( dict ( cmds = [ cmd ] ) )