Example #1
0
    def ClientConnected(self, response_topic, messageSequence=1, **msginfo):
        """
        由GS向SC调用
        注意:response_topic应为sc_group_topic,而不是具体的sc
        :param recv_topic:sc
        :param messageSequence:
        :param client_id:
        :param service_instance_id:
        :param app_id:
        :param client_name:
        :param response_topic: GS
        :return:
        """
        listenthread = self._CreateListenThread(messageSequence, pb_sc,
                                                "ClientConnectedRsp",
                                                response_topic)

        if self.lock.acquire():
            sleep(1)
            self.lock.release()
            msg_body = pb_sc.ClientConnected(**msginfo).SerializeToString()
            buf = self.createMsg(
                messageSequence, response_topic,
                pb_sc.ProtoDictionary.Value("Enum2ClientConnected"), msg_body)
            self.producer.send(SC_GROUP_TOPIC, buf)
            rspdata = self._getRspdata(listenthread)
            return rspdata
Example #2
0
    def ClientConnected(messageSequence, client_id, service_instance_id, app_id, client_name, uuid, response_topic):
        clientconnected = pb_sc.ClientConnected()
        clientconnected.client_id = client_id
        clientconnected.service_instance_id = service_instance_id
        clientconnected.app_id = app_id
        clientconnected.client_name = client_name

        clientconnected.commonInvokeInfo.CopyFrom(getCommonInvokeInfo(uuid, "DFD"))
        msg_body = clientconnected.SerializeToString()
        command_id = pb_sc.ProtoDictionary.Value('Enum2ClientConnected')
        return createMsg(messageSequence, command_id, msg_body, response_topic)
Example #3
0
def ClientConnected(messageSequence, client_id, service_instance_id, app_id,
                    client_name, response_topic):

    clientconnected = pb_sc.ClientConnected()
    clientconnected.client_id = client_id
    clientconnected.service_instance_id = service_instance_id
    clientconnected.app_id = app_id
    clientconnected.client_name = client_name
    clientconnected_msg = clientconnected.SerializeToString()
    messageNumber = pb_sc.ProtoDictionary.Value('Enum2ClientConnected')

    fmt = "!BBqB%dsi" % (len(response_topic))
    # here the topic is for produce, not for consumer
    msgprefix = struct.pack(fmt, 1, 1, messageSequence, len(response_topic),
                            response_topic, messageNumber)
    # s = bytes(clientconnected_msg)
    cpt = pb_sc.ClientConnected()
    cpt.ParseFromString(clientconnected_msg)
    # print cpt.client_id
    # print cpt.app_id
    # print s
    # print clientconnected_msg
    buf = msgprefix + clientconnected_msg
    return buf