def doStartNewSession(self, arg): """ Action method. """ from transport.udp import udp_session peer_address = arg if self.node.my_address is None: if _Debug: lg.out( _DebugLevel, 'udp_connector.doStartNewSession to %s at %s SKIP because my_address is None' % (self.peer_id, peer_address)) return active_sessions = udp_session.get(peer_address) if active_sessions: if _Debug: lg.out(_DebugLevel, 'udp_connector.doStartNewSession SKIP because found existing by peer address %s : %s' % ( peer_address, active_sessions, )) return active_sessions = udp_session.get_by_peer_id(self.peer_id) if active_sessions: if _Debug: lg.out(_DebugLevel, 'udp_connector.doStartNewSession SKIP because found existing by peer id %s : %s' % ( self.peer_id, active_sessions, )) return s = udp_session.create(self.node, peer_address, self.peer_id) s.automat('init', (self.listen_port, self.my_id, self.my_address))
def doStartNewSession(self, arg): """ Action method. """ from transport.udp import udp_session peer_address = arg if self.node.my_address is None: if _Debug: lg.out( _DebugLevel, 'udp_connector.doStartNewSession to %s at %s SKIP because my_address is None' % (self.peer_id, peer_address)) return s = udp_session.get(peer_address) if s: if _Debug: lg.out( _DebugLevel, 'udp_connector.doStartNewSession SKIP because found existing : %s' % s) return s = udp_session.get_by_peer_id(self.peer_id) if s: if _Debug: lg.out( _DebugLevel, 'udp_connector.doStartNewSession SKIP because found existing by peer id:%s %s' % (self.peer_id, s)) return s = udp_session.create(self.node, peer_address, self.peer_id) s.automat('init', (self.listen_port, self.my_id, self.my_address))
def doCheckAndStartNewSession(self, arg): """ Action method. """ if self.my_address is None: if _Debug: lg.out( _DebugLevel, 'dp_node.doCheckAndStartNewSession SKIP because my_address is None' ) return incoming_str = arg if incoming_str is None: return try: incoming_user_id, incoming_user_address, time_placed = incoming_str.split( ' ') incoming_user_address = incoming_user_address.split(':') incoming_user_address[1] = int(incoming_user_address[1]) incoming_user_address = tuple(incoming_user_address) except: if _Debug: lg.out(_DebugLevel, '%r' % incoming_str) lg.exc() return active_sessions = udp_session.get(incoming_user_address) if active_sessions: if _Debug: lg.out( _DebugLevel, 'udp_node.doCheckAndStartNewSessions SKIP because found existing by address %s : %s' % ( incoming_user_address, active_sessions, )) return active_sessions = udp_session.get_by_peer_id(incoming_user_id) if active_sessions: if _Debug: lg.out( _DebugLevel, 'udp_node.doCheckAndStartNewSession SKIP because found existing by peer id %s : %s' % ( incoming_user_id, active_sessions, )) return if _Debug: lg.out( _DebugLevel, 'udp_node.doCheckAndStartNewSession wants to start a new session with incoming peer %s at %s' % (incoming_user_id, incoming_user_address)) s = udp_session.create(self, incoming_user_address, incoming_user_id) s.automat('init')
def doCheckAndStartNewSession(self, arg): """ Action method. """ if self.my_address is None: if _Debug: lg.out( _DebugLevel, 'dp_node.doCheckAndStartNewSession SKIP because my_address is None') return incoming_str = arg if incoming_str is None: return try: incoming_user_id, incoming_user_address, time_placed = incoming_str.split( ' ') incoming_user_address = incoming_user_address.split(':') incoming_user_address[1] = int(incoming_user_address[1]) incoming_user_address = tuple(incoming_user_address) except: if _Debug: lg.out(_DebugLevel, '%r' % incoming_str) lg.exc() return s = udp_session.get(incoming_user_address) if s: if _Debug: lg.out( _DebugLevel, 'udp_node.doCheckAndStartNewSessions SKIP because found existing %s' % s) return s = udp_session.get_by_peer_id(incoming_user_id) if s: if _Debug: lg.out( _DebugLevel, 'udp_node.doCheckAndStartNewSession SKIP because found existing by peer id:%s %s' % (incoming_user_id, s)) return if _Debug: lg.out( _DebugLevel, 'udp_node.doCheckAndStartNewSession wants to start a new session with incoming peer %s at %s' % (incoming_user_id, incoming_user_address)) s = udp_session.create(self, incoming_user_address, incoming_user_id) s.automat('init')
def doStartNewSession(self, arg): """ Action method. """ try: datagram, address = arg command, payload = datagram except: lg.exc() return if _Debug: lg.out( _DebugLevel, 'udp_node.doStartNewSession wants to start a new session with UNKNOWN peer at %s' % str(address)) s = udp_session.create(self, address) s.automat('init') s.automat('datagram-received', arg)