• Anthony Minessale's avatar
    more event stuff · ab0b99eb
    Anthony Minessale 提交于
    you should now be able to bind an event handler to a 
    paticiular file or function not just a paticular event
    when using the custom event 
    
    like "file:somefile.c"
    or "func:somefunc"
    
    also events now have headers which can be added 
    with varargs and should be created and delivered with api calls
    
    
    switch_event *event;
    
    regular event:
    if (switch_event_create(&event, SWITCH_EVENT_STARTUP) == SWITCH_STATUS_SUCCESS) {
    	switch_event_add_header(event, "event_info", "System Ready");
    	switch_event_fire(&event);
    }
    
    custom event:
    if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, "some_subclass_string") == SWITCH_STATUS_SUCCESS) {
    	switch_event_add_header(event, "event_info", "hello world %d", 42);
    	switch_event_fire(&event);
    } 
    
    switch_event_add_header(event, "test %d", 42);
    
    also you can serialize and event into a buffer in
    a printable/transferrable format with optional body
    
    char buf[1024];
    
    with body:
    switch_event_serialize(event, buf, sizeof(buf), "This is a body my favorite number is %d", 42);
    
    no body:
    switch_event_serialize(event, buf, sizeof(buf), NULL);
    
    
    
    
    
    
    git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@173 d0543943-73ff-0310-b7d9-9358b9ac24b2
    ab0b99eb
switch_event.h 3.2 KB