silc_schedule_task_add_event

SYNOPSIS

    SilcTask
    silc_schedule_task_add_event(SilcSchedule schedule,
                                 const char *event, ...);

DESCRIPTION

Adds an event task to scheduler. These tasks are asynchronous events that one or more receivers may connect to and receive information or data when the event is signalled. Event tasks are fast and may be used to efficiently deliver events and data to multiple receivers. The `event' is the name of the event, and can be used to connect to the event and to signal it.

The events are global among the `scheduler', its parent scheduler and any of its child schedulers. It does not matter to which scheduler event is added to, connected to or signalled. Signal will reach any connected entity, as long as it is the parent or one of the fellow children of `schedule'.

To connect to an event call silc_schedule_event_connect. To disconnect from event call silc_schedule_event_disconnect. To signal event call silc_schedule_event_signal. To delete event task call silc_schedule_task_del or silc_schedule_task_del_event.

The variable argument list is used to describe the arguments of the event. The variable arguments are a list of zero or more SilcParam values. The list must be ended with SILC_PARAM_END. This function returns the event task context or NULL on error.

EXAMPLE

    // Register 'connected' event
    silc_schedule_task_add_event(schedule, "connected",
                                 SILC_PARAM_UINT32,
                                 SILC_PARAM_BUFFER,
                                 SILC_PARAM_END);

    // Connect to 'connected' event
    silc_schedule_event_connect(schedule, "connected", NULL,
                                connected_cb, ctx);

    // Signal 'connected' event
    silc_schedule_event_signal(schedule, "connected", NULL, integer, buf);

    // 'connected' event handler
    SILC_TASK_CALLBACK(connected_cb)
    {
      FooCtx ctx = context;
      SilcUInt32 integer;
      SilcBuffer buf;

      integer = va_arg(va, SilcUInt32);
      buf = va_arg(va, SilcBuffer);
      ...
    }