Beispiel #1
0
 def _on_end_delimiter(self, frame):
     """ Override the default on_message handler to decode first """
     if not self.client_terminated:
         self.async_callback(self._on_message)(smart_str(frame[:-1]))
         # self.async_callback(self._on_message)(
         #         frame[:-1].decode("utf-8", "replace"))
         self._receive_message()
Beispiel #2
0
 def post(self, *args, **kwargs):
     self.set_header('Content-Type', 'text/plain')
     data = self.get_argument('data')
     self.async_callback(self._on_message)(smart_str(data))
     # self.async_callback(self._on_message)(
     #         data.decode("utf-8", "replace"))
     self.write('ok')
     self.finish()
Beispiel #3
0
 def _write(self, message):
     """Sends the given message to the client of this Web Socket."""
     if isinstance(message, dict):
         message = tornado.escape.json_encode(message)
     if isinstance(message, unicode):
         message = smart_str(message)
         # message = message.encode("utf-8")
     assert isinstance(message, str)
     self.stream.write("\x00" + message + "\xff")
Beispiel #4
0
 def post(self, *args, **kwargs):
     self.set_header('Content-Type', 'text/plain')
     data = self.get_argument('data')
     if not self.preflight():
         raise tornado.web.HTTPError(401, "unauthorized")
     self.async_callback(self._on_message)(smart_str(data))
     # self.async_callback(self._on_message)(
     #         data.decode("utf-8", "replace"))
     self.write('ok')
     self.finish()