def queue_event_hook(event):
    if event == rservr.RSERVR_QUEUE_MESSAGE:
        while True:
            try:
                message = rservr.current_message()
            except IndexError:
                break
            try:
                if message.is_info():
                    print >> sys.stderr, 'info message: "%s"' % (message.to_info_message())
                    response = rservr.short_response(message, rservr.event_complete)
                    rservr.send_command_no_status(response)
                    rservr.destroy_command(response)
                elif message.is_request_single():
                    print >> sys.stderr, 'request message: "%s"' % (message.to_request_single())
                    response = rservr.client_response(message, rservr.event_complete, message.to_request_single())
                    rservr.send_command_no_status(response)
                    rservr.destroy_command(response)
            except (TypeError, IndexError, RuntimeError):
                pass
            rservr.remove_message(message)
def queue_event_hook(event):
    if event == rservr.RSERVR_QUEUE_MESSAGE:
        while True:
            try:
                message = rservr.current_message()
            except IndexError:
                break
            try:
                if message.is_info():
                    print >>sys.stderr, 'info message: "%s"' % (message.to_info_message())
                    response = rservr.short_response(message, rservr.event_complete)
                    rservr.send_command_no_status(response)
                    rservr.destroy_command(response)
                elif message.is_request_single():
                    print >>sys.stderr, 'request message: "%s"' % (message.to_request_single())
                    response = rservr.client_response(message, rservr.event_complete, message.to_request_single())
                    rservr.send_command_no_status(response)
                    rservr.destroy_command(response)
            except (TypeError, IndexError, RuntimeError):
                pass
            rservr.remove_message(message)
import rservr.rsvp_rqsrvc


print >> sys.stderr, 'starting message queue...'
rservr.start_message_queue()

print >> sys.stderr, 'registering client...'
rservr.register_resource_client()


print >> sys.stderr, 'registering service...'
service = rservr.register_service(sys.argv[1], 'echo')

reference = rservr.send_command(service)
rservr.destroy_command(service)
status = rservr.wait_command_event(reference)
rservr.clear_command_status(reference)

if not (status & rservr.event_complete):
    raise RuntimeError('service registration failed with status %.4x' % (status))

rservr.set_log_client_name(sys.argv[1])


def queue_event_hook(event):
    if event == rservr.RSERVR_QUEUE_MESSAGE:
        while True:
            try:
                message = rservr.current_message()
            except IndexError:
import rservr.rsvp_rqsrvc


print >>sys.stderr, "starting message queue..."
rservr.start_message_queue()

print >>sys.stderr, "registering client..."
rservr.register_resource_client()


print >>sys.stderr, "registering service..."
service = rservr.register_service(sys.argv[1], "echo")

reference = rservr.send_command(service)
rservr.destroy_command(service)
status = rservr.wait_command_event(reference)
rservr.clear_command_status(reference)

if not (status & rservr.event_complete):
    raise RuntimeError("service registration failed with status %.4x" % (status))

rservr.set_log_client_name(sys.argv[1])


def queue_event_hook(event):
    if event == rservr.RSERVR_QUEUE_MESSAGE:
        while True:
            try:
                message = rservr.current_message()
            except IndexError: