コード例 #1
0
    def get_network_list(self, cb):
        packet = proto.RemoteCommand()
        packet.packet_type = proto.RemoteCommand.GetNetworkList

        def handle_response(packet):
            if packet.packet_type == proto.RemoteMessage.NetworkList:
                cb(packet.network_list)
            else:
                self.logger('Unknown reply to GetNetworkList: ' + str(packet))

        self.write_packet(packet, handle_response)
コード例 #2
0
    def get_buffer_list(self, network_id, cb):
        packet = proto.RemoteCommand()
        packet.packet_type = proto.RemoteCommand.GetBufferList
        packet.network_id = network_id

        def handle_response(packet):
            if packet.packet_type == proto.RemoteMessage.BufferList:
                cb(packet.network_id, packet.buffer_list)
            else:
                self.logger('Unknown reply to GetBufferList: ' + str(packet))

        self.write_packet(packet, handle_response)
コード例 #3
0
    def attach_session(self, id, cb):
        packet = proto.RemoteCommand()
        packet.packet_type = proto.RemoteCommand.AttachSession
        packet.attach_session.session_id = id

        def handle_response(packet):
            if packet.packet_type == proto.RemoteMessage.Error:
                cb(False)
            elif packet.packet_type == proto.RemoteMessage.Success:
                cb(True)
            else:
                self.logger('Unknown reply to AttachSession: ' + str(packet))
                cb(False)

        self.write_packet(packet, handle_response)
コード例 #4
0
    def get_network_configuration(self, network_id, cb):
        packet = proto.RemoteCommand()
        packet.packet_type = proto.RemoteCommand.GetNetworkConfiguration
        packet.network_id = network_id

        def handle_response(packet):
            if packet.packet_type == proto.RemoteMessage.NetworkConfiguration:

                if packet.HasField('network_configuration'):
                    cb(packet.network_id, packet.network_configuration)
                else:
                    cb(packet.network_id, False)
            else:
                self.logger('Unknown reply to GetNetworkConfiguration: ' +
                            str(packet))

        self.write_packet(packet, handle_response)
コード例 #5
0
 def send_connect(self, network_id, address):
     packet = proto.RemoteCommand()
     packet.packet_type = proto.RemoteCommand.Connect
     packet.network_id = network_id
     packet.connect.address = address
     self.write_packet(packet, cb)