Python asyncore 模块,dispatcher_with_send() 实例源码

我们从Python开源项目中,提取了以下27个代码示例,用于说明如何使用asyncore.dispatcher_with_send()

项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def __init__(self, host, port):
        """
        Object constructor.
        :param host: The Frostbite2 server host
        :param port: The Frostbite2 server port
        """
        asyncore.dispatcher_with_send.__init__(self)
        self._buffer_in = ''
        self.getLogger().info("connecting")
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        asyncore.dispatcher_with_send.connect(self, (host, port))
        self._frostbite_event_handler = None
        self._frostbite_command_response_handler = None

    ####################################################################################################################
    #                                                                                                                  #
    #   PUBLIC API                                                                                                     #
    #                                                                                                                  #
    ####################################################################################################################
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def send_command(self, *command):
        """
        Send a command to the Frosbite server and return the command
        id which can be used to find the matching reply later on.
        """
        self.getLogger().info("command : %s " % repr(command))
        if len(command) == 1 and type(command[0]) == tuple:
            words = command[0]
        else:
            words = command

        request = EncodeClientRequest(words)
        [sequence, words] = DecodePacket(request)[2:]

        self.getLogger().debug("sending command request #%i: %s " % (sequence, words))
        asyncore.dispatcher_with_send.send(self, request)

        return sequence

    ####################################################################################################################
    #                                                                                                                  #
    #   OTHER METHODS                                                                                                  #
    #                                                                                                                  #
    ####################################################################################################################
项目:esys-pbi    作者:fsxfreak    | 项目源码 | 文件源码
def __init__(self,sock,time_fn):
        self.time_fn = time_fn
        asyncore.dispatcher_with_send.__init__(self,sock)
项目:aquests    作者:hansroh    | 项目源码 | 文件源码
def __init__(self, consumer, query, host, port=43):
        asyncore.dispatcher_with_send.__init__(self)

        self.consumer = consumer
        self.query = query

        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.connect((host, port))
项目:aquests    作者:hansroh    | 项目源码 | 文件源码
def __init__(self,*name,**args):
        DnsRequest.__init__(self, *name, **args)        
        asyncore.dispatcher_with_send.__init__(self)
        # XXX todo
        if 'done' in args and args['done']:
            self.donefunc=args['done']
        else:
            self.donefunc=self.showResult
        #self.realinit(name,args) # XXX todo
        self.async=1
项目:continuum    作者:zyantific    | 项目源码 | 文件源码
def __init__(self, sock, core):
        asyncore.dispatcher_with_send.__init__(self, sock=sock)
        ProtoMixin.__init__(self)
        QObject.__init__(self)
        self.core = core
        self.idb_path = GetIdbPath()

        self.send_packet({
            'kind': 'new_client',
            'input_file': GetInputFile(),
            'idb_path': GetIdbPath(),
            'pid': os.getpid(),
        })

        print("[continuum] Connected.")
项目:continuum    作者:zyantific    | 项目源码 | 文件源码
def handle_close(self):
        asyncore.dispatcher_with_send.handle_close(self)
        print("[continuum] Connection lost, reconnecting.")
        self.core.create_client()
项目:continuum    作者:zyantific    | 项目源码 | 文件源码
def __init__(self, sock, server):
        # We need to use old-style init calls here because asyncore 
        # consists of old-style classes :(
        asyncore.dispatcher_with_send.__init__(self, sock=sock)
        ProtoMixin.__init__(self)

        self.input_file = None
        self.idb_path = None
        self.server = server
        self.project = server.core.project
        self.server.clients.add(self)
项目:continuum    作者:zyantific    | 项目源码 | 文件源码
def handle_close(self):
        self.server.clients.remove(self)
        self.server.update_idb_client_map()
        print("[continuum] A client disconnected.")
        asyncore.dispatcher_with_send.handle_close(self)
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def __init__(self, conn, certfile):
                    self.socket = ssl.wrap_socket(conn, server_side=True,
                                                  certfile=certfile,
                                                  do_handshake_on_connect=False)
                    asyncore.dispatcher_with_send.__init__(self, self.socket)
                    self._ssl_accepting = True
                    self._do_ssl_handshake()
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def __init__(self, conn, certfile):
                    self.socket = ssl.wrap_socket(conn, server_side=True,
                                                  certfile=certfile,
                                                  do_handshake_on_connect=False)
                    asyncore.dispatcher_with_send.__init__(self, self.socket)
                    self._ssl_accepting = True
                    self._do_ssl_handshake()
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def __init__(self, conn, certfile):
                    self.socket = ssl.wrap_socket(conn, server_side=True,
                                                  certfile=certfile,
                                                  do_handshake_on_connect=False)
                    asyncore.dispatcher_with_send.__init__(self, self.socket)
                    self._ssl_accepting = True
                    self._do_ssl_handshake()
项目:karlooper    作者:karldoenitz    | 项目源码 | 文件源码
def __init__(self, async_socket, handlers, settings):
        """async echo handler based on asyncore.dispatcher_with_send

        :param async_socket: the socket object
        :param handlers: handlers mapping
        :param settings: settings config

        """
        self.logger = logging.getLogger()
        self.__handlers = handlers
        self.__settings = settings
        asyncore.dispatcher_with_send.__init__(self, sock=async_socket)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def __init__(self, conn, certfile):
                    self.socket = ssl.wrap_socket(conn, server_side=True,
                                                  certfile=certfile,
                                                  do_handshake_on_connect=False)
                    asyncore.dispatcher_with_send.__init__(self, self.socket)
                    self._ssl_accepting = True
                    self._do_ssl_handshake()
项目:futuquant    作者:FutunnOpen    | 项目源码 | 文件源码
def __init__(self, host, port, handler_ctx, close_handler=None):
        self.__host = host
        self.__port = port
        self.__close_handler = close_handler

        asyncore.dispatcher_with_send.__init__(self)
        self._socket_create_and_connect()

        time.sleep(0.1)
        self.rsp_buf = b''
        self.handler_ctx = handler_ctx
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def __init__(self, conn, certfile):
                    self.socket = ssl.wrap_socket(conn, server_side=True,
                                                  certfile=certfile,
                                                  do_handshake_on_connect=False)
                    asyncore.dispatcher_with_send.__init__(self, self.socket)
                    self._ssl_accepting = True
                    self._do_ssl_handshake()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def __init__(self, conn, certfile):
                    self.socket = ssl.wrap_socket(conn, server_side=True,
                                                  certfile=certfile,
                                                  do_handshake_on_connect=False)
                    asyncore.dispatcher_with_send.__init__(self, self.socket)
                    self._ssl_accepting = True
                    self._do_ssl_handshake()
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def __init__(self, conn, certfile):
                    asyncore.dispatcher_with_send.__init__(self, conn)
                    self.socket = ssl.wrap_socket(conn, server_side=True,
                                                  certfile=certfile,
                                                  do_handshake_on_connect=False)
                    self._ssl_accepting = True
项目:lewis    作者:DMSC-Instrument-Data    | 项目源码 | 文件源码
def __init__(self, sock, interface, server):
        asyncore.dispatcher_with_send.__init__(self, sock=sock)
        self._datastore = ModbusDataStore(interface.di, interface.co, interface.ir, interface.hr)
        self._modbus = ModbusProtocol(self.send, self._datastore)
        self._server = server

        self._set_logging_context(interface)
        self.log.info('Client connected from %s:%s', *sock.getpeername())
项目:MarkovObfuscate    作者:CylanceSPEAR    | 项目源码 | 文件源码
def __init__(self, markov, sock, remote_server, remote_port):
            self.markov = markov
            asyncore.dispatcher_with_send.__init__(self, sock)
            msock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            msock.connect((remote_server, remote_port))
            self.msock = LocalProxy.ToMTunnelServer(markov, self, msock)
项目:MarkovObfuscate    作者:CylanceSPEAR    | 项目源码 | 文件源码
def __init__(self, markov, sock, oSock):
            self.read_buffer = ''
            self.markov = markov
            asyncore.dispatcher_with_send.__init__(self, oSock)
            self.client = sock
项目:MarkovObfuscate    作者:CylanceSPEAR    | 项目源码 | 文件源码
def __init__(self, markov, sock):
            self.read_buffer = ''
            self.markov = markov
            #self.msock = MTunnelServer.ToRemoteServer(markov, self, msock)
            self.msock = None
            self.state = 0
            asyncore.dispatcher_with_send.__init__(self, sock)
            self.state_lock = threading.RLock()
项目:MarkovObfuscate    作者:CylanceSPEAR    | 项目源码 | 文件源码
def __init__(self, markov, sock, oSock):
            self.markov = markov
            asyncore.dispatcher_with_send.__init__(self, oSock)
            self.client = sock
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def __init__(self, conn, certfile):
                    self.socket = ssl.wrap_socket(conn, server_side=True,
                                                  certfile=certfile,
                                                  do_handshake_on_connect=False)
                    asyncore.dispatcher_with_send.__init__(self, self.socket)
                    self._ssl_accepting = True
                    self._do_ssl_handshake()
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def __init__(self, host, port, packet_queue=None):
        asyncore.dispatcher_with_send.__init__(self)
        self.log = logging.getLogger("RavagedDispatcher")
        self._buffer_in = ''
        self.packet_queue = packet_queue if packet_queue else Queue()
        self.log.info("connecting")
        self.create_socket(AF_INET, SOCK_STREAM)
        self.connect((host, port))

    ####################################################################################################################
    #                                                                                                                  #
    #   PUBLIC API                                                                                                     #
    #                                                                                                                  #
    ####################################################################################################################
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def __init__(self, console, host, port, password, keepalive=False):
        asyncore.dispatcher_with_send.__init__(self)
        self.console = console
        self._host = host
        self._port = port
        self._password = password
        self.keepalive = keepalive
        self._buffer_in = ''
        self.authed = False
        self.server_version = None
        self.last_pong_time = self.last_ping_time = time.time()
        self._handlers = set()
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.connect( (self._host, self._port) )
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def __init__(self, console, host, port, password, packetListener):
        asyncore.dispatcher_with_send.__init__(self)
        self.console = console
        self._host = host
        self._port = port
        self._password = password
        self._packetListener = packetListener
        self.isAuthed = False
        self.keepalive = True
        self.readBuffer = ""
        self.console.info("Starting RCON for game server %s:%s" % (host, port))
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.connect((self._host, self._port))