websocket调用特殊说明

接口描述

  • websocket交互协议

建立连接时的请求数据

机器人与服务端建立连接示例:

    {
		"chatid": "61fdae8f-8005-48ae-853f-180ab1715421",
		"peerChatid": "qubb_1578390845523_human",
		"robot": "GBQ4",
		"reOpenFlag": "0"
	}
	

训练师与服务端建立连接示例:

	reOpenFlag为1表示重连,0表示初次连接
    {
		"chatid": "qubb_1578390845523_human",
		"peerChatid": "61fdae8f-8005-48ae-853f-180ab1715421",
		"robot": "GBQ4",
		"reOpenFlag": "0"
	}
	

心跳时的交互数据

机器人端心跳数据:

	发送
   {
		"msgType": "ping",
		"chatid": "61fdae8f-8005-48ae-853f-180ab1715421",
		"peerChatid": "qubb_1578390845523_human"
	}
	
	收到
	{
		"msgType": "pong"
	}
	

训练师端心跳数据:

	发送
   {
		"msgType": "ping",
		"chatid": "qubb_1578390845523_human",
		"peerChatid": "61fdae8f-8005-48ae-853f-180ab1715421"
	}
	
	收到
	{
		"msgType": "pong"
	}
	

问答时的交互数据

训练师发送数据示例:

    {
		"chatid": "qubb_1578390845523_human",
		"peerChatid": "61fdae8f-8005-48ae-853f-180ab1715421",
		"robot": "GBQ4",
		"content": "你好",
		"msgType": "text",
		"role": "ms",
		"time": "2020-01-07 17:54:54"
	}
	服务端将此消息转发给机器人
	

用户发送数据示例:

    {
		"chatid": "61fdae8f-8005-48ae-853f-180ab1715421",
		"peerChatid": "qubb_1578390845523_human",
		"robot": "GBQ4",
		"content": "嗯",
		"msgType": "text",
		"role": "app",
		"time": "2020-01-07 17:55:45"
	}
	服务端将此消息转发给训练师
	

关闭时的交互数据

服务端发送给客户端的关闭示例:

	断网后恢复
    {
		"chatid": "c960732a-dc17-444f-84f2-8efacba7ae23",
		"msgType": "close_offline",
		"peerChatid": "gaoh-j_1578571096323_human"
	}
	
	服务端异常退出
	{
		"chatid": "c960732a-dc17-444f-84f2-8efacba7ae23",
		"msgType": "close_exception",
		"peerChatid": "gaoh-j_1578571096323_human"
	}
	
	3分钟无交互退出
	{
		"chatid": "c960732a-dc17-444f-84f2-8efacba7ae23",
		"msgType": "close_session",
		"peerChatid": "gaoh-j_1578571096323_human"
	}
	

websocket调用流程图