from sseclient import SSEClient


def get_expId(url,sessionId,streamId,token):
    '''
    url:sse连接地址；
    sessionId：会话Id
    streamId：本次对话Id
    token：凭据
    '''
    params = {
        'sessionId':sessionId,
        'streamId':streamId,
        'access_token':token
    }
    messages = SSEClient(url=url,params=params)
    for msg in messages:
        # 处理每个接收到的消息
        if 'EXP' in msg.data:
            # print("Received Message:", msg.data)
            return msg.data
            break

# print(get_expId('http://bitagent.sit.ninetechone.com/api/chat/read','CB_05ae462bcf704b5aa990c0db9b3496cb','CB_ec83a379621a4eddb7360fcd7272b1e0','Bearer c1391926-e8ba-46c0-a0d1-c5e3c38503da'))