emiago / diago

Short of Dialog + GO. Library/Framework for building VOIP solutions in GO
Mozilla Public License 2.0
82 stars 7 forks source link

NewDiago replaces sipgo.Server's handlers #17

Open Qjawko opened 2 days ago

Qjawko commented 2 days ago

Hi,

I am trying to customize the OPTIONS handler response to fit my specific requirements. However, when I call diago.NewDiago with my own sipgo.Server that has a defined OPTIONS handler, Diago overrides it with its own implementation.

I will submit a PR that modifies this behavior so that Diago checks for already registered methods and avoids replacing them.

Thank you!

SilvaMendes commented 2 days ago

but why didn't I add validation to server.OnInvite as well? Do you have an example of how you are customizing the methods?

Qjawko commented 1 day ago

but why didn't I add validation to server.OnInvite as well? Do you have an example of how you are customizing the methods?

I don't think that someone will need it, because diago already handles RTP streaming (inside sipgo handler) and other stuff.

Here is an example

srv, _ := sipgo.NewServer(ua)

srv.OnOptions(func(req *sip.Request, tx sip.ServerTransaction) {
    // do your stuff
})

dg := diago.NewDiago(ua, diago.WithServer(srv))
SilvaMendes commented 1 day ago

ok, i understand