def handle(self): """Handle an association request. * Creates a new Association acceptor instance and configures it. * Sets the Association's socket to the request's socket. * Starts the Association reactor. """ from pynetdicom.association import Association assoc = Association(self.ae, MODE_ACCEPTOR) # Set the thread name timestamp = datetime.strftime(datetime.now(), "%Y%m%d%H%M%S") assoc.name = "AcceptorThread@{}".format(timestamp) sock = AssociationSocket(assoc, client_socket=self.request) assoc.set_socket(sock) # Association Acceptor object -> local AE assoc.acceptor.maximum_length = self.ae.maximum_pdu_size assoc.acceptor.ae_title = self.ae.ae_title assoc.acceptor.address = self.local[0] assoc.acceptor.port = self.local[1] assoc.acceptor.implementation_class_uid = ( self.ae.implementation_class_uid) assoc.acceptor.implementation_version_name = ( self.ae.implementation_version_name) assoc.acceptor.supported_contexts = deepcopy( self.ae.supported_contexts) # Association Requestor object -> remote AE assoc.requestor.address = self.remote[0] assoc.requestor.port = self.remote[1] assoc.start()
def handle(self): """Handle an association request. * Creates a new Association acceptor instance and configures it. * Sets the Association's socket to the request's socket. * Starts the Association reactor. """ from pynetdicom.association import Association assoc = Association(self.ae, MODE_ACCEPTOR) assoc._server = self.server # Set the thread name timestamp = datetime.strftime(datetime.now(), "%Y%m%d%H%M%S") assoc.name = "AcceptorThread@{}".format(timestamp) sock = AssociationSocket(assoc, client_socket=self.request) assoc.set_socket(sock) # Association Acceptor object -> local AE assoc.acceptor.maximum_length = self.ae.maximum_pdu_size assoc.acceptor.ae_title = self.ae.ae_title assoc.acceptor.address = self.local[0] assoc.acceptor.port = self.local[1] assoc.acceptor.implementation_class_uid = ( self.ae.implementation_class_uid ) assoc.acceptor.implementation_version_name = ( self.ae.implementation_version_name ) assoc.acceptor.supported_contexts = deepcopy( self.ae.supported_contexts ) # Association Requestor object -> remote AE assoc.requestor.address = self.remote[0] assoc.requestor.port = self.remote[1] # Bind events to handlers for event in self.server._handlers: # Intervention events if event.is_intervention and self.server._handlers[event]: assoc.bind(event, self.server._handlers[event]) elif event.is_notification: for handler in self.server._handlers[event]: assoc.bind(event, handler) # Trigger must be after binding the events evt.trigger( assoc, evt.EVT_CONN_OPEN, {'address' : self.client_address} ) assoc.start()