Skip to content

Event Handling in a Handy Way

Knugi edited this page Jun 5, 2020 · 5 revisions

This fork provide you a handy way to add event handlers as well as more events than the original repo!

How to bind an event handler

Simply define a handler function and add a decorator above the function with the event name. Something like this:

@Event.add("onConnect") # event name inside the bracket
def onConnect_handler(client, *args):
    print("App '{0}' is connected!".format(client.path))
---
agent = FlashServer() # Before you create an instance of the server

Please note that, do not use this way to add event handlers together with the traditional way!

List of subscribable event

onConnect

Firing condition

When a client connect to the server

Argument Passed

  • client: instance of the client connection
  • *args: TODO

onDisconnect

Firing condition

When a client disconnect from the server

Argument Passed

  • client: instance of the client connection

onPublish

Firing condition

When a client (feed) started to broadcasting stream feed

Argument Passed

  • client: instance of the client connection
  • stream: TODO

onClose

Firing condition

When a client (feed) stop broadcasting stream feed

Argument Passed

  • client: instance of the client connection
  • stream: TODO

onPlay

Firing condition

When a client (viewer) started to play the stream

Argument Passed

  • client: instance of the client connection
  • stream: TODO

onStop

Firing condition

When a client (viewer) stop the play of a stream

Argument Passed

  • client: instance of the client connection
  • stream: TODO

onCommand

Firing condition

When a server received a command packet from a client

Argument Passed

  • client: instance of the client connection
  • cmd: command sent by client
  • *args: TODO

onStatus

Firing condition

Argument Passed

  • client: instance of the client connection
  • info: TODO

onResult

Firing condition

Argument Passed

  • client: instance of the client connection
  • result: TODO

onPublishData

Firing condition

When the server received a media data packet

Argument Passed

  • client: instance of the client connection
  • stream: TODO
  • message: TODO

onPlayData

Firing condition

When the server sent a media data packet

Argument Passed

  • client: instance of the client connection
  • stream: TODO
  • message: TODO

onUnpublish

Firing condition

When a stream is unpublish

Argument Passed

  • client: instance of the client connection
  • cmd: command sent by client

onDelete

Firing condition

When a stream being deleted

Argument Passed

  • client: instance of the client connection
  • cmd: command sent by client