网络聊天室通信协议

一、注册
1、注册命令格式:0x01|username(20字节)|password(20字节)|sex(1字节)|age(4字节)|address(100字节)|job(64字节)|phone(20字节)|email(64字节)|interest(64字节)|
2、注册成功应答:0x02|QQNum(20字节)|
3、注册失败应答:0x03|reason(1字节)| 0x01:username exist already

二、登陆
1、登陆命令格式:0x04|QQId(20字节)|password(20字节)|
2、登陆成功应答:0x05|onlineFriendNum(4字节)|FriendName1(20字节)|FriendName2(20字节)|...|FriendNameN(20字节)|
3、登陆失败应答:0x06|reason(1字节)| 0x02: username not exist 0x03: login already 0x04: password incorrect

三、刷新在线列表请求:
1、请求命令格式:0x07|QQId(20字节)
2、成功应答格式:0x08|onlineFriendNum(4字节)|FriendName1(20字节)|FriendName2(20字节)|...|FriendNameN(20字节)|
3、失败应答格式:0x09|reason(1字节)| 0x02:username not exist 0x05:user not login yet

四、好友私聊:
1、好友私聊命令:0x0a|QQId(20字节)|FriendName(20字节)|ContentLength(4字节)|chatContent(字节数为ContentLength)|
2、好友私聊转发应答:0x0b|username(20字节)|ContentLength(4字节)|chatContent(字节数为ContentLength)|
3、失败应答:0x0c|reason(1字节)| 0x02: username not exist 0x05:user not login yet 0x06:friend not exist 0x07:friend ont online now

五、群聊:
1、群聊命令:0x0d|QQId(20字节)|ContentLength(4字节)|chatContent(字节数为ContentLength)|
2、群聊转发应答:0x0e|username(20字节)|ContentLength(4字节)|chatContent(字节数为ContentLength)|
3、失败应答:0x0f|reason(1字节)| 0x02: username not exist 0x05:user not login yet 0x07: friend not online now

六、退出:
1、退出命令:0x10|QQId(20字节)

七、查看好友个人信息:
1、命令格式:0x11|QQId(20字节)|FriendName(20字节)|
2、成功应答: 0x12|sex(1字节)|age(4字节)|address(100字节)|job(64字节)|phone(20字节)|email(64字节)|interest(64)字节|
3、失败应答:0x13|reason(1字节)| 0x02: username not exist 0x05 user not login yet 0x06 friend not exist





相关文档
最新文档