Hi Gabi,

o Gabriel [10/10/08 16:55]:
> Hi,
> 
> i want to create my own AmEvent to send it from one thread to another.
> this event needs an event_id, can i give it a random number or is there
> any specification to this id?
you can assign it any id you like. In the core, the Events are checked 
for their class types (see lots of dynamic_cast in AmSession::process).

If you want to optimize this, then define an ID for your event and check 
for the ID before trying to cast. E.g. like this:

#define FANCY_EVENT_ID 100 // should be unique

class FancyEvent : public AmEvent {
  FancyEvent() : AmEvent(FANCY_EVENT_ID) { }
   ...
};

...
MySession::process(AmEvent* ev) {

...
  if (ev->event_id == FANCY_EVENT_ID) {
    FancyEvent* f_ev = dynamice_cast<FancyEvent*>(ev);
    if (f_ev) {
     ... do sth with f_ev...
    }
  }

then you don't try casting with a lot of other events (SipRequestEvent etc).

If you have some spare minutes, you could also do that for the core, and 
post a patch, or upload it to the tracker, what do you think?

Stefan

> 
> --
> Gabriel
> 
> _______________________________________________
> Semsdev mailing list
> [email protected]
> http://lists.iptel.org/mailman/listinfo/semsdev

-- 
Stefan Sayer
VoIP Services

[EMAIL PROTECTED]
www.iptego.com

IPTEGO GmbH
Am Borsigturm 40
13507 Berlin
Germany

Amtsgericht Charlottenburg, HRB 101010
Geschaeftsfuehrer: Alexander Hoffmann
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to