[SIP Beyond VoIP] SIP Simple in existing reactor loop

Saúl Ibarra Corretgé saul at ag-projects.com
Wed Jan 8 10:19:20 CET 2014


Hi,

On Jan 7, 2014, at 8:38 PM, Chris Maciejewski <chris at wima.co.uk> wrote:

> Hi,
> 
> I am having a hard time running SIP Simple in Twisted based GTK+ 3.0
> application:
> 
> https://twistedmatrix.com/documents/current/core/howto/choosing-reactor.html#auto12
> 
> Example code below:
> 
> from twisted.internet import gtk3reactor
> gtk3reactor.install()
> 
> from gi.repository import Gtk, Gio
> from zope.interface import implements
> from sipsimple.application import SIPApplication
> from sipsimple.storage import MemoryStorage
> 
> class SipSimpleTestApp(Gtk.Application):
> 
>  def __init__(self):
>    Gtk.Application.__init__(self,
> application_id="apps.test.SipSimpleTestApp",
> flags=Gio.ApplicationFlags.FLAGS_NONE)
>    self.connect("activate", self.on_activate)
> 
>  def on_activate(self, data=None):
> 
>    window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
>    window.set_title("SIP Simple Hello World")
>    label = Gtk.Label("SIP Simple Hello World")
>    window.add(label)
>    window.show_all()
> 
>    self.add_window(window)
> 
>    self.sip = SIPApplication();
>    self.sip.start(MemoryStorage());
> 
> if __name__ == "__main__":
>    app = SipSimpleTestApp()
>    from twisted.internet import reactor
>    reactor.registerGApplication(app)
>    reactor.run()
> 
> Throws ReactorAlreadyRunning exception.
> 
> Any suggestions what would be the best approach to run SIPApplication
> inside of GTK reactor GUI very much appreciated.
> 

The SDK takes care of starting and stopping the reactor, so in your app you shouldn't call reactor.run(), as it will be called by SIPApplication.start. Also note that SIP SIMPLE SDK runs the reactor in a separated thread, not the main thread, so you'll have to join it from the main thread or do something to prevent the program from exiting.


Regards,

--
Saúl Ibarra Corretgé
AG Projects





More information about the SIPBeyondVoIP mailing list