pyphoenix.phoenix

Main Phoenix application class.

Functions

create_app()

Create a new Phoenix application instance.

Classes

Phoenix()

Main Phoenix application class.

class pyphoenix.phoenix.Phoenix[source]

Main Phoenix application class.

This is the central coordination point for the PyPhoenix application, managing transports, channels, and providing the main API.

__init__()[source]

Initialize the Phoenix application.

channel(topic_pattern)[source]

Decorator to register a channel handler for a topic pattern.

Parameters:

topic_pattern (str) – Topic pattern to handle (e.g., “room:*”)

Returns:

Decorator function

async start(host='localhost', port=4000)[source]

Start the Phoenix application.

Parameters:
  • host (str) – Host to bind to

  • port (int) – Port to bind to

Return type:

None

async stop()[source]

Stop the Phoenix application.

Return type:

None

async route_message(socket, message)[source]

Route incoming message to appropriate channel.

Parameters:
  • socket – The socket that received the message

  • message (Message) – The parsed message

Return type:

None

async get_or_create_channel(topic, socket)[source]

Get existing channel or create new one from registered handlers.

Parameters:
  • topic (str) – The channel topic

  • socket – The socket requesting the channel

Return type:

Optional[Channel]

Returns:

Channel instance or None if no pattern matches

match_topic_pattern(pattern, topic)[source]

Match topic against pattern (support wildcards).

Parameters:
  • pattern (str) – Pattern like “room:” or “user:”

  • topic (str) – Actual topic like “room:lobby” or “user:123”

Return type:

bool

Returns:

True if topic matches pattern

run(host='localhost', port=4000, **kwargs)[source]

Run the Phoenix application (blocking).

Parameters:
  • host (str) – Host to bind to

  • port (int) – Port to bind to

  • **kwargs – Additional arguments (for future use)

Return type:

None

pyphoenix.phoenix.create_app()[source]

Create a new Phoenix application instance.

Return type:

Phoenix