Anonymous avatar Anonymous committed a1dd897

Auto detect Orbited.settings.hostname and Orbited.settings.port; Required morbid for install; Allow Orbited to use morbid to act as an embedded stomp broker.

Comments (0)

Files changed (5)

daemon/orbited-debug.cfg

 [global]
 reactor=epoll
 proxy.enabled=1
+morbid.enabled=1
 session.ping_interval = 60
 session.ping_timeout = 70
 

daemon/orbited/config.py

     '[global]': {
         #'reactor': 'epoll',
 
-        #'proxy.enabled': '1',
-
+        'proxy.enabled': '1',
         'pid.location': '/tmp/orbited.pid',
         'session.ping_interval': '30',
         'session.ping_timeout': '30'

daemon/orbited/start.py

             factory_class = _import(factory_class_import)
             reactor.listenWith(port_class, factory=factory_class(), resource=root, childName=child_path)
             logger.info('%s protocol active' % config_key)
-
+    
 def _setup_static(root, config):
     from twisted.web import static
     for key, val in config['[static]'].items():
     # we can now safely get loggers.
     global logger; logger = logging.get_logger('orbited.start')
 
+
     # NB: we need to install the reactor before using twisted.
     reactor_name = config.map['[global]'].get('reactor')
     if reactor_name:
     root = resource.Resource()
     static_files = static.File(os.path.join(os.path.dirname(__file__), 'static'))
     root.putChild('static', static_files)
+    #static_files.putChild('orbited.swf', static.File(os.path.join(os.path.dirname(__file__), 'flash', 'orbited.swf')))
     site = server.Site(root)
 
     _setup_protocols(root)
 
 def start_listening(site, config, logger):
     from twisted.internet import reactor
+    # allow stomp:// URIs to be parsed by urlparse 
+    urlparse.uses_netloc.append('stomp')
+
     for addr in config['[listen]']:
         url = urlparse.urlparse(addr)
         hostname = url.hostname or ''
-        if url.scheme == 'http':
+        if url.scheme == 'stomp':
+            logger.info('Listening stomp@%s' % url.port)
+            from morbid import StompFactory
+            reactor.listenTCP(url.port, StompFactory(), interface=hostname)     
+        elif url.scheme == 'http':
             logger.info('Listening http@%s' % url.port)
             reactor.listenTCP(url.port, site, interface=hostname)
         elif url.scheme == 'https':

daemon/orbited/static/Orbited.js

 }
 Orbited.JSON = JSON;
 
+
 })();
+
+
+// Try to auto detect the Orbited port and hostname
+(function() {
+try {
+    var scripts = document.getElementsByTagName('script')
+    for (var i = 0; i < scripts.length; ++i) {
+        var script = scripts[0]
+        if (script.src.match('/static/Orbited\.js$')) {
+            var url = new Orbited.URL(script.src)
+            Orbited.settings.hostname = url.domain;
+            Orbited.settings.port = url.port;
+            break
+        }
+    }
+} catch(e) { }
+})()
     '*.template'
 ]
 
-_install_requires = [ "demjson" ]
+_install_requires = [ "demjson", "morbid" ]
 
 #if sys.platform != "win32":
 #    _install_requires.append("Twisted")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.