增加数据包 COMBO_SEND ENTRY_EFFECT PK_AGAIN PK_CLICK_AGAIN

This commit is contained in:
czp3009 2018-07-28 19:29:48 +08:00
parent b9c5b57dd4
commit f010aa77ef
14 changed files with 602 additions and 3 deletions

View File

@ -22,10 +22,11 @@ B站不少参数都是瞎取的, 并且不统一, 经常混用, 以下给出一
| :--- | :--- |
| mid | 用户 ID(与 userId 含义一致, 经常被混用) |
| userId | 用户 ID, 用户在B站的唯一标识, 数字 |
| uid | 用户 ID, 与 userId 同义 |
| userid | 注意这里是全小写, 它的值可能是 'bili_1178318619', 这个东西是没用的, B站并不用这个作为用户唯一标识 |
| showRoomId | 直播间 URL (Web)上的房间号 |
| showRoomId | 直播间 URL (Web)上的房间号(可能是一个很小的数字, 低于 1000) |
| roomId | 直播间的真实 ID(直播房间号在 1000 以下的房间, 真实 ID 是另外一个数字) |
| cid | 直播间 ID(URL 上的房间号以及真实房间号都叫 cid) |
| cid | 直播间 ID(URL 上的房间号以及真实房间号都叫 cid) |
| ruid | 直播间房主的用户 ID |
# 使用
@ -321,14 +322,18 @@ API 文档
| ActivityEventPackageEvent | 收到 ACTIVITY_EVENT 数据包 |
| ChangeRoomInfoPackageEvent | 收到 CHANGE_ROOM_INFO 数据包 |
| ComboEndPackageEvent | 收到 COMBO_END 数据包 |
| ComboSendPackageEvent | 收到 COMBO_SEND 数据包 |
| ConnectionCloseEvent | 连接断开(主动或被动) |
| ConnectSucceedEvent | 进房成功 |
| CutOffPackageEvent | 收到 CUT_OFF 数据包 |
| DanMuMsgPackageEvent | 收到 DANMU_MSG 数据包 |
| EntryEffectPackageEvent | 收到 ENTRY_EFFECT 数据包 |
| EventCmdPackageEvent | 收到 EVENT_CMD 数据包 |
| GuardBuyPackageEvent | 收到 GUARD_BUY 数据包 |
| GuardMsgPackageEvent | 收到 GUARD_MSG 数据包 |
| LivePackageEvent | 收到 LIVE 数据包 |
| PkAgainPackageEvent | 收到 PK_AGAIN 数据包 |
| PkClickAgainPackageEvent | 收到 PK_CLICK_AGAIN 数据包 |
| PkEndPackageEvent | 收到 PK_END 数据包 |
| PkMatchPackageEvent | 收到 PK_MATCH 数据包 |
| PkMicEndPackageEvent | 收到 PK_MIC_END 数据包 |

View File

@ -0,0 +1,11 @@
{
"cmd": "COMBO_SEND",
"data": {
"uid": 33012231,
"uname": "我就是讨厌你这样",
"combo_num": 3,
"gift_name": "凉了",
"gift_id": 20010,
"action": "赠送"
}
}

View File

@ -0,0 +1,16 @@
{
"cmd": "ENTRY_EFFECT",
"data": {
"id": 3,
"uid": 9359447,
"target_id": 275592903,
"show_avatar": 1,
"copy_writing": "欢迎 \u003c%藏拙当成玉%\u003e 进入房间",
"highlight_color": "#FFF100",
"basemap_url": "http://i0.hdslb.com/bfs/live/d208b9654b93a70b4177e1aa7e2f0343f8a5ff1a.png",
"effective_time": 1,
"priority": 50,
"privilege_type": 0,
"face": "http://i1.hdslb.com/bfs/face/12cb1ea6eea79667e3fb722bbd8995bb96f4cd6f.jpg"
}
}

View File

@ -0,0 +1,17 @@
{
"cmd": "PK_AGAIN",
"pk_id": 60672,
"pk_status": 400,
"data": {
"new_pk_id": 60678,
"init_id": 10817769,
"match_id": 1489926,
"escape_all_time": 10,
"escape_time": 10,
"is_portrait": false,
"uname": "穆阿是给你的mua",
"face": "http://i0.hdslb.com/bfs/face/07fa1057b60afe74cdd477f123c6ccf460ee8f2c.jpg",
"uid": 38105366
},
"roomid": 1489926
}

View File

@ -0,0 +1,6 @@
{
"pk_status": 400,
"pk_id": 60672,
"cmd": "PK_CLICK_AGAIN",
"roomid": 1489926
}

View File

@ -0,0 +1,104 @@
package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class ComboSendEntity implements DataEntity {
/**
* cmd : COMBO_SEND
* data : {"uid":33012231,"uname":"我就是讨厌你这样","combo_num":3,"gift_name":"凉了","gift_id":20010,"action":"赠送"}
*/
@SerializedName("cmd")
private String cmd;
@SerializedName("data")
private Data data;
@Override
public String getCmd() {
return cmd;
}
public void setCmd(String cmd) {
this.cmd = cmd;
}
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
public static class Data {
/**
* uid : 33012231
* uname : 我就是讨厌你这样
* combo_num : 3
* gift_name : 凉了
* gift_id : 20010
* action : 赠送
*/
@SerializedName("uid")
private long uid;
@SerializedName("uname")
private String userName;
@SerializedName("combo_num")
private int comboNumber;
@SerializedName("gift_name")
private String giftName;
@SerializedName("gift_id")
private int giftId;
@SerializedName("action")
private String action;
public long getUid() {
return uid;
}
public void setUid(long uid) {
this.uid = uid;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public int getComboNumber() {
return comboNumber;
}
public void setComboNumber(int comboNumber) {
this.comboNumber = comboNumber;
}
public String getGiftName() {
return giftName;
}
public void setGiftName(String giftName) {
this.giftName = giftName;
}
public int getGiftId() {
return giftId;
}
public void setGiftId(int giftId) {
this.giftId = giftId;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
}
}

View File

@ -0,0 +1,159 @@
package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class EntryEffectEntity implements DataEntity {
/**
* cmd : ENTRY_EFFECT
* data : {"id":3,"uid":9359447,"target_id":275592903,"show_avatar":1,"copy_writing":"欢迎 <%藏拙当成玉%> 进入房间","highlight_color":"#FFF100","basemap_url":"http://i0.hdslb.com/bfs/live/d208b9654b93a70b4177e1aa7e2f0343f8a5ff1a.png","effective_time":1,"priority":50,"privilege_type":0,"face":"http://i1.hdslb.com/bfs/face/12cb1ea6eea79667e3fb722bbd8995bb96f4cd6f.jpg"}
*/
@SerializedName("cmd")
private String cmd;
@SerializedName("data")
private Data data;
@Override
public String getCmd() {
return cmd;
}
public void setCmd(String cmd) {
this.cmd = cmd;
}
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
public static class Data {
/**
* id : 3
* uid : 9359447
* target_id : 275592903
* show_avatar : 1
* copy_writing : 欢迎 <%藏拙当成玉%> 进入房间
* highlight_color : #FFF100
* basemap_url : http://i0.hdslb.com/bfs/live/d208b9654b93a70b4177e1aa7e2f0343f8a5ff1a.png
* effective_time : 1
* priority : 50
* privilege_type : 0
* face : http://i1.hdslb.com/bfs/face/12cb1ea6eea79667e3fb722bbd8995bb96f4cd6f.jpg
*/
@SerializedName("id")
private long id;
@SerializedName("uid")
private long uid;
@SerializedName("target_id")
private long targetId;
@SerializedName("show_avatar")
private int showAvatar;
@SerializedName("copy_writing")
private String copyWriting;
@SerializedName("highlight_color")
private String highlightColor;
@SerializedName("basemap_url")
private String baseMapUrl;
@SerializedName("effective_time")
private int effectiveTime;
@SerializedName("priority")
private int priority;
@SerializedName("privilege_type")
private int privilegeType;
@SerializedName("face")
private String face;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getUid() {
return uid;
}
public void setUid(long uid) {
this.uid = uid;
}
public long getTargetId() {
return targetId;
}
public void setTargetId(long targetId) {
this.targetId = targetId;
}
public int getShowAvatar() {
return showAvatar;
}
public void setShowAvatar(int showAvatar) {
this.showAvatar = showAvatar;
}
public String getCopyWriting() {
return copyWriting;
}
public void setCopyWriting(String copyWriting) {
this.copyWriting = copyWriting;
}
public String getHighlightColor() {
return highlightColor;
}
public void setHighlightColor(String highlightColor) {
this.highlightColor = highlightColor;
}
public String getBaseMapUrl() {
return baseMapUrl;
}
public void setBaseMapUrl(String baseMapUrl) {
this.baseMapUrl = baseMapUrl;
}
public int getEffectiveTime() {
return effectiveTime;
}
public void setEffectiveTime(int effectiveTime) {
this.effectiveTime = effectiveTime;
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
public int getPrivilegeType() {
return privilegeType;
}
public void setPrivilegeType(int privilegeType) {
this.privilegeType = privilegeType;
}
public String getFace() {
return face;
}
public void setFace(String face) {
this.face = face;
}
}
}

View File

@ -0,0 +1,170 @@
package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class PkAgainEntity implements DataEntity {
/**
* cmd : PK_AGAIN
* pk_id : 60672
* pk_status : 400
* data : {"new_pk_id":60678,"init_id":10817769,"match_id":1489926,"escape_all_time":10,"escape_time":10,"is_portrait":false,"uname":"穆阿是给你的mua","face":"http://i0.hdslb.com/bfs/face/07fa1057b60afe74cdd477f123c6ccf460ee8f2c.jpg","uid":38105366}
* roomid : 1489926
*/
@SerializedName("cmd")
private String cmd;
@SerializedName("pk_id")
private long pkId;
@SerializedName("pk_status")
private int pkStatus;
@SerializedName("data")
private Data data;
@SerializedName("roomid")
private long roomId;
@Override
public String getCmd() {
return cmd;
}
public void setCmd(String cmd) {
this.cmd = cmd;
}
public long getPkId() {
return pkId;
}
public void setPkId(long pkId) {
this.pkId = pkId;
}
public int getPkStatus() {
return pkStatus;
}
public void setPkStatus(int pkStatus) {
this.pkStatus = pkStatus;
}
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
public long getRoomId() {
return roomId;
}
public void setRoomId(long roomId) {
this.roomId = roomId;
}
public static class Data {
/**
* new_pk_id : 60678
* init_id : 10817769
* match_id : 1489926
* escape_all_time : 10
* escape_time : 10
* is_portrait : false
* uname : 穆阿是给你的mua
* face : http://i0.hdslb.com/bfs/face/07fa1057b60afe74cdd477f123c6ccf460ee8f2c.jpg
* uid : 38105366
*/
@SerializedName("new_pk_id")
private long newPkId;
@SerializedName("init_id")
private long initId;
@SerializedName("match_id")
private long matchId;
@SerializedName("escape_all_time")
private int escapeAllTime;
@SerializedName("escape_time")
private int escapeTime;
@SerializedName("is_portrait")
private boolean isPortrait;
@SerializedName("uname")
private String userName;
@SerializedName("face")
private String face;
@SerializedName("uid")
private long uid;
public long getNewPkId() {
return newPkId;
}
public void setNewPkId(long newPkId) {
this.newPkId = newPkId;
}
public long getInitId() {
return initId;
}
public void setInitId(long initId) {
this.initId = initId;
}
public long getMatchId() {
return matchId;
}
public void setMatchId(long matchId) {
this.matchId = matchId;
}
public int getEscapeAllTime() {
return escapeAllTime;
}
public void setEscapeAllTime(int escapeAllTime) {
this.escapeAllTime = escapeAllTime;
}
public int getEscapeTime() {
return escapeTime;
}
public void setEscapeTime(int escapeTime) {
this.escapeTime = escapeTime;
}
public boolean isIsPortrait() {
return isPortrait;
}
public void setIsPortrait(boolean isPortrait) {
this.isPortrait = isPortrait;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getFace() {
return face;
}
public void setFace(String face) {
this.face = face;
}
public long getUid() {
return uid;
}
public void setUid(long uid) {
this.uid = uid;
}
}
}

View File

@ -0,0 +1,54 @@
package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class PkClickAgainEntity implements DataEntity {
/**
* pk_status : 400
* pk_id : 60672
* cmd : PK_CLICK_AGAIN
* roomid : 1489926
*/
@SerializedName("pk_status")
private int pkStatus;
@SerializedName("pk_id")
private long pkId;
@SerializedName("cmd")
private String cmd;
@SerializedName("roomid")
private long roomId;
public int getPkStatus() {
return pkStatus;
}
public void setPkStatus(int pkStatus) {
this.pkStatus = pkStatus;
}
public long getPkId() {
return pkId;
}
public void setPkId(long pkId) {
this.pkId = pkId;
}
@Override
public String getCmd() {
return cmd;
}
public void setCmd(String cmd) {
this.cmd = cmd;
}
public long getRoomId() {
return roomId;
}
public void setRoomId(long roomId) {
this.roomId = roomId;
}
}

View File

@ -0,0 +1,10 @@
package com.hiczp.bilibili.api.live.socket.event;
import com.hiczp.bilibili.api.live.socket.LiveClient;
import com.hiczp.bilibili.api.live.socket.entity.ComboSendEntity;
public class ComboSendPackageEvent extends ReceiveDataPackageEvent<ComboSendEntity> {
public ComboSendPackageEvent(LiveClient source, ComboSendEntity entity) {
super(source, entity);
}
}

View File

@ -0,0 +1,10 @@
package com.hiczp.bilibili.api.live.socket.event;
import com.hiczp.bilibili.api.live.socket.LiveClient;
import com.hiczp.bilibili.api.live.socket.entity.EntryEffectEntity;
public class EntryEffectPackageEvent extends ReceiveDataPackageEvent<EntryEffectEntity> {
public EntryEffectPackageEvent(LiveClient source, EntryEffectEntity entity) {
super(source, entity);
}
}

View File

@ -0,0 +1,10 @@
package com.hiczp.bilibili.api.live.socket.event;
import com.hiczp.bilibili.api.live.socket.LiveClient;
import com.hiczp.bilibili.api.live.socket.entity.PkAgainEntity;
public class PkAgainPackageEvent extends ReceiveDataPackageEvent<PkAgainEntity> {
public PkAgainPackageEvent(LiveClient source, PkAgainEntity entity) {
super(source, entity);
}
}

View File

@ -0,0 +1,10 @@
package com.hiczp.bilibili.api.live.socket.event;
import com.hiczp.bilibili.api.live.socket.LiveClient;
import com.hiczp.bilibili.api.live.socket.entity.PkClickAgainEntity;
public class PkClickAgainPackageEvent extends ReceiveDataPackageEvent<PkClickAgainEntity> {
public PkClickAgainPackageEvent(LiveClient source, PkClickAgainEntity entity) {
super(source, entity);
}
}

View File

@ -92,7 +92,11 @@ public class LiveClientHandler extends SimpleChannelInboundHandler<Package> {
eventType = SendGiftPackageEvent.class;
}
break;
//TODO 尚不明确 COMBO_END 是什么意思
//combo
case "COMBO_SEND": {
eventType = ComboSendPackageEvent.class;
}
break;
case "COMBO_END": {
eventType = ComboEndPackageEvent.class;
}
@ -112,6 +116,11 @@ public class LiveClientHandler extends SimpleChannelInboundHandler<Package> {
eventType = WelcomeGuardPackageEvent.class;
}
break;
//TODO 尚不明确 EntryEffect 和普通 Welcome 的区别
case "ENTRY_EFFECT": {
eventType = EntryEffectPackageEvent.class;
}
break;
//PK
case "PK_MATCH": {
eventType = PkMatchPackageEvent.class;
@ -141,6 +150,14 @@ public class LiveClientHandler extends SimpleChannelInboundHandler<Package> {
eventType = PkSettlePackageEvent.class;
}
break;
case "PK_AGAIN": {
eventType = PkAgainPackageEvent.class;
}
break;
case "PK_CLICK_AGAIN": {
eventType = PkClickAgainPackageEvent.class;
}
break;
//系统消息(小电视等)
case "SYS_MSG": {
eventType = SysMsgPackageEvent.class;