def send_message_async(client_id, message): """Send a message to a channel asynchronously. Based off of App Engine's channel.send_message function. """ if isinstance(message, unicode): message = message.encode('utf-8') request = channel_service_pb.SendMessageRequest() response = api_base_pb.VoidProto() request.set_application_key(client_id) request.set_message(message) rpc = apiproxy_stub_map.UserRPC(channel._GetService()) rpc.make_call('SendChannelMessage', request, response) yield rpc try: raise ndb.Return(rpc.get_result()) except apiproxy_errors.ApplicationError, e: raise channel._ToChannelError(e)
def main(): from google.appengine.api.channel.channel import _GetService logging.info('channel service type: %s' % _GetService()) util.run_wsgi_app(application)