parameters: (request, message)
docstring: Sends ping to the server. Just so we know client is still alive. It also removes old locks. This is not the place to do it at all,
      but once we have normal scheduled calls, will put it there.
      :Args:
        - request (:class:`django.http.HttpRequest`): Client Request object
        - message (dict): Message object
docstring_summary: Sends ping to the server. Just so we know client is still alive. It also removes old locks. This is not the place to do it at all,
      but once we have normal scheduled calls, will put it there.
      :Args:
        - request (:class:`django.http.HttpRequest`): Client Request object
        - message (dict): Message object
docstring_tokens: Sends ping to the server . Just so we know client is still alive . It also removes old locks . This is not the place to do it at all but once we have normal scheduled calls will put it there . : Args : - request ( : class : django . http . HttpRequest ) : Client Request object - message ( dict ) : Message object
function: def remote_ping(request, message):
      """
      Sends ping to the server. Just so we know client is still alive. It also removes old locks. This is not the place to do it at all,
      but once we have normal scheduled calls, will put it there.
      :Args:
        - request (:class:`django.http.HttpRequest`): Client Request object
        - message (dict): Message object
      """
  
      import sputnik
  
      sputnik.addMessageToChannel(request, "/booktype/", {})
  
      # kill old chapters which are no longer under edit
      keys = sputnik.rkeys("booktype:*:*:editlocks:*")
  
      for key in keys:
          last_ping = sputnik.get(key)
  
          try:
              last_ping = decimal.Decimal(last_ping)
          except Exception as e:
              logger.exception(e)
  
          if last_ping and decimal.Decimal("%f" % time.time()) - last_ping > Chapter.EDIT_PING_SECONDS_MAX_DELTA:
              sputnik.rdelete(key)
              m = re.match("booktype:(\d+):(\d+).(\d+):editlocks:(\d+):(\w+)", key)
  
              if m:
                  bookid, version, chapter_id, username = (m.group(1), "{0}.{1}".format(m.group(2), m.group(3)),
                                                           m.group(4), m.group(5))
  
                  sputnik.addMessageToChannel(request, "/booktype/book/%s/%s/" % (bookid, version),
                                              {"command": "chapter_state",
                                               "chapterID": chapter_id,
                                               "state": "normal",
                                               "username": username},
                                              myself=True)
function_tokens: def remote_ping ( request , message ) : import sputnik sputnik . addMessageToChannel ( request , "/booktype/" , { } ) # kill old chapters which are no longer under edit keys = sputnik . rkeys ( "booktype:*:*:editlocks:*" ) for key in keys : last_ping = sputnik . get ( key ) try : last_ping = decimal . Decimal ( last_ping ) except Exception as e : logger . exception ( e ) if last_ping and decimal . Decimal ( "%f" % time . time ( ) ) - last_ping > Chapter . EDIT_PING_SECONDS_MAX_DELTA : sputnik . rdelete ( key ) m = re . match ( "booktype:(\d+):(\d+).(\d+):editlocks:(\d+):(\w+)" , key ) if m : bookid , version , chapter_id , username = ( m . group ( 1 ) , "{0}.{1}" . format ( m . group ( 2 ) , m . group ( 3 ) ) , m . group ( 4 ) , m . group ( 5 ) ) sputnik . addMessageToChannel ( request , "/booktype/book/%s/%s/" % ( bookid , version ) , { "command" : "chapter_state" , "chapterID" : chapter_id , "state" : "normal" , "username" : username } , myself = True )