通信协议
4V通信协议
1. 通信方式
使用HTTPS的POST方式通信
2.1 POST请求基本格式
| 1 | { | 
2.2 请求结果的返回格式
| 1 | { | 
2.3 校验
- 1.将token、timestamp、nonce、response/request四个参数进行升序排序;
- 2.将四个参数字符串拼接成一个字符串进行sha256加密;
- 3.获得加密后的字符串与signature对比,确认该信息来源于发送方。
2.4 加密
- 当encrypt值为1时, request/response为进行了AES加密的加密串。
- 当encrypt值为0时不对request/response进行加密。  2.5 消息响应
- 接收方不响应时间戳与服务器时间差过大的消息,直接返回超时。  2.6 错误响应
- 当发生错误时接收方的给请求方的response应为如下格式:
 response:说明:1 {"status":2,"message":"XXXX错误/异常/拒绝访问…"} 
 status为错误码(大于等于2的int值),message为消息文本。
3.1 服务器登陆
登陆时外层token为空,请求时encrypt为0
请求1
2
3
4
5
6{
    "type":"loginServer",
    "name":"admin",
    "pwd":"2b2374mdiqpzmdbdrewidj129dkixjkl", // sha256()
    "secret":"321jhufiwqh2i3hu189321",        // 本次登陆aes密码
}
回应1
2
3
4
5
6
7
8{
    "type":"loginServer",
    "status":1, // 登陆正常
    "token":"321321kjfduisafvj764321ndjsagy3",
    "expires":7200,
    "features":{// 功能列表
    },
}
3.2 服务器退出登陆
退出时外层token为登陆时的token。
请求1
2
3{
    "type":"logoutServer",
}
回应1
2
3
4{
    "type":"logoutServer",
    "status":1, // 退出成功,服务器设置token过期
}
3.3 服务器修改密码
请求1
2
3
4
5
6{
    "type":"changePassword",
    "name":"user1",
    "pwdold":"2b2374mdiqpzmdbdrewidj129dkixjkl", // sha256
    "pwdnew":"2b2374mdiqpzmdbdrewidj129dkixjkl", // sha256
}
回应1
2
3
4{
    "type":"changePassword",
    "status":1, // 成功
}
3.4 配置4V信息
请求1
2
3
4
5{
    "type":"configInfo",
    "features":{
    },
}
回应1
2
3
4{
    "type":"configInfo",
    "status":1, // 成功
}
3.5 登陆4V
请求1
2
3
4
5{
    "type":"login",
    "name":"admin",
    "pwd":"",
}
回应1
2
3
4
5{
    "type":"login",
    "status":1, // 成功
    "token":"",// 4V token
}
3.6 退出4v登陆
请求1
2
3
4{
    "type":"logout",
    "token":"",// token
}
回应1
2
3
4{
    "type":"logout",
    "status":1, // 退出成功,服务器设置token过期
}
3.7 修改4v密码
请求1
2
3
4
5
6{
    "type":"changePassword",
    "name":"admin",
    "pwdold":"123456", // sha256
    "pwdnew":"1234567", // sha256
}
回应1
2
3
4{
    "type":"changePassword",
    "status":1, // 成功
}





