コード例 #1
0
    def get_websocket_url(self, server_id, stream_name, target_url):
        ''' Get the url of the websocket for the specified stream of the
            specified server; if websocket server does not exist, start it.

                server_id:      The id of the server.

                stream_name:    The name of the stream ('out' or 'pub').

                target_url:     The relative url at which to serve the websocket.
        '''
        if stream_name not in ['out', 'pub']:
            print >>sys.stderr, \
                "ZMQServerManager - Invalid stream requested:", stream_name
            return None

        server_info = self.server_dict[server_id]

        ws_url_key = stream_name + '_ws_url'
        if ws_url_key in server_info:
            return server_info[ws_url_key]
        else:
            ws_port = get_unused_ip_port()
            ws_url = 'ws://%s:%d%s' % (self.address, ws_port, target_url)
            server_info[stream_name + '_ws_server'] = \
                ZMQStreamServer.spawn_process(server_info[stream_name+'_url'],
                                              ws_port, target_url, self.external)
            server_info[ws_url_key] = ws_url
            return ws_url
コード例 #2
0
 def get_out_server_url(self, server_id, ws_url):
     ''' get the output socket web server for the server associated with
         an id, create one if none exists
     '''
     server_info = self.server_dict[server_id]
     if 'out_server' in server_info:
         return server_info['out_server_url']
     else:
         ws_port = get_unused_ip_port()
         ws_addr = 'ws://localhost:%d%s' % (ws_port, ws_url)
         server_info['out_server'] = ZMQStreamServer.spawn_process(server_info['out_url'], ws_port, ws_url)
         server_info['out_server_url'] = ws_addr
         return ws_addr
コード例 #3
0
 def get_out_server_url(self, server_id, ws_url):
     ''' get the output socket web server for the server associated with
         an id, create one if none exists
     '''
     server_info = self.server_dict[server_id]
     if 'out_server' in server_info:
         return server_info['out_server_url']
     else:
         ws_port = get_unused_ip_port()
         ws_addr = 'ws://localhost:%d%s' % (ws_port, ws_url)
         server_info['out_server'] = ZMQStreamServer.spawn_process(
             server_info['out_url'], ws_port, ws_url)
         server_info['out_server_url'] = ws_addr
         return ws_addr
コード例 #4
0
 def get_pub_server_url(self, server_id, ws_url):
     ''' get the publisher socket web server for the server associated with
         an id, create one if none exists
     '''
     server_info = self.server_dict[server_id]
     if 'pub_server' in server_info:
         return server_info['pub_server_url']
     else:
         ws_port = get_unused_ip_port()
         ws_addr = 'ws://%s:%d%s' % (self.address, ws_port, ws_url)
         server_info['pub_server'] = \
             ZMQStreamServer.spawn_process(server_info['pub_url'],
                                           ws_port, ws_url, self.external)
         server_info['pub_server_url'] = ws_addr
         return ws_addr
コード例 #5
0
 def get_pub_server_url(self, server_id, ws_url):
     ''' get the publisher socket web server for the server associated with
         an id, create one if none exists
     '''
     server_info = self.server_dict[server_id]
     if 'pub_server' in server_info:
         return server_info['pub_server_url']
     else:
         ws_port = get_unused_ip_port()
         ws_addr = 'ws://%s:%d%s' % (self.address, ws_port, ws_url)
         server_info['pub_server'] = \
             ZMQStreamServer.spawn_process(server_info['pub_url'],
                                           ws_port, ws_url, self.external)
         server_info['pub_server_url'] = ws_addr
         return ws_addr