vortex — PyVortex base module: base functions (create listeners, register profiles)

This modules includes all functions required to establish a BEEP session, create channels and develop BEEP profiles.

This module also includes type definition for the following classes:

Module API

vortex.create_listener(ctx, host, port)

Allows to create a BEEP listener to receiving incoming connections. Here is an example:

# create a listener
listener = vortex.create_listener (ctx, "0.0.0.0", "44010")

# check listener started
if not listener.is_ok ():
    # do some error handling
    sys.exit (-1)

# do a wait operation
vortex.wait_listeners (ctx, unlock_on_signal=True)
Parameters:
  • ctx (vortex.Ctx) – vortex context where the listener will be created
  • host (String) – the hostname
  • port (String) – the port to connect to
Return type:

vortex.Connection representing the listener created.

vortex.wait_listeners(ctx[, unlock_on_signal])

Allows to perform a wait operation until vortex context is finished or due to a signal received.

Parameters:
  • ctx (vortex.Ctx) – context where a listener or a set of listener were created.
  • unlock_on_signal (Integer: True or False) – unlock_on_signal expects to receive True to make wait_listener to unlock on signal received.
vortex.unlock_listeners(ctx)

Allows to unlock the thread that is blocked at wait_listeners call

Parameters:ctx (vortex.Ctx) – context where a listener or a set of listener were created.
vortex.register_profile(ctx = vortex.Ctx, uri[, start][, start_data][, close][, close_data][, frame_received][, frame_received_data])

Allows to register a supported profile so the current BEEP, inside the provided vortex.Ctx will accept incoming requests to open a channel running such profile.

The function requires to mandatory parameters (ctx and uri). The rest of parameters are handlers used to handle different situations (start channel request, close channel request, and frame received).

Parameters:
  • ctx (vortex.Ctx) – context where the profile will be registered
  • uri (string) – Profile unique string identification
  • start (Channel start handler) – User defined handler that will be used to manage incoming start channel requests. The handler must provide return True to accept the channel to be created or False to deny it.
  • start_data (object) – User defined data that will notified along with corresponding data at start handler.
  • close (Channel close handler) – User defined handler that will be used to manage incoming close channel requests. The handler must provide return True to accept the channel to be closed or False to deny it.
  • close_data (object) – User defined data that will notified along with corresponding data at close channel handler.
  • frame_received (Frame received handler) – User defined handler that will be used to manage frames received under channels running this profile.
  • frame_received_data (object) – User defined data that will notified along with corresponding data at frame received handler.

To register a profile with a simple handler do:

# register the profile
vortex.register_profile (ctx, "urn:your-domain:beep:profiles:my-app-profile",
                         frame_received=my_app_frame_received)

Check Frame received handler to get details about frame received handler (my_app_frame_received).

vortex.queue_reply(conn, channel, frame, o)

Function used inside the queue reply method. This function is used as frame received handler, queuring all frames in the queue provided as user data. The, a call to channel.get_reply (queue) is required to get all frames received.

Here is an example:

# configure frame received handler
queue = vortex.AsyncQueue ()
channel.set_frame_received (vortex.queue_reply, queue)

# wait for frames to be received
frame = channel.get_reply (queue)