示例#1
0
                      default=8000,
                      dest="port",
                      help="port number to serve")
    parser.add_option("-d",
                      default="localhost",
                      dest="domain",
                      help="domain to serve")
    parser.add_option("-l",
                      action="store_true",
                      dest="log_debug",
                      help="log debugging output")
    (options, args) = parser.parse_args()

    amfast.log_debug = options.log_debug

    channel_set = WsgiChannelSet()
    rpc_channel = WsgiChannel('amf')
    channel_set.mapChannel(rpc_channel)
    utils.setup_channel_set(channel_set)

    server = simple_server.WSGIServer((options.domain, int(options.port)),
                                      simple_server.WSGIRequestHandler)

    server.set_app(channel_set)

    try:
        print "Serving on %s:%s" % (options.domain, options.port)
        print "Press ctrl-c to halt."
        server.serve_forever()
    except KeyboardInterrupt:
        pass
示例#2
0
    handler = logging.StreamHandler(sys.stdout)
    handler.setLevel(logging.DEBUG)
    amfast.logger.addHandler(handler)

    cp_options = {
        'global': {
            'server.socket_port': int(options.port),
            'server.socket_host': str(options.domain),
        },
        '/': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': os.path.join(os.getcwd(), '../flex/deploy')
        }
    }

    channel_set = WsgiChannelSet(notify_connections=False)

    # Clients connect every x seconds
    # to polling channels to check for messages.
    # If messages are available, they are
    # returned to the client.
    polling_channel = WsgiChannel('amf')
    channel_set.mapChannel(polling_channel)

    # Long-poll channels do not return
    # a response to the client until
    # a message is available, or channel.max_interval
    # is reached.
    long_poll_channel = WsgiChannel('longPoll', wait_interval=90)
    channel_set.mapChannel(long_poll_channel)