From f010aa77ef1074fb1423f777e0adc9931052965d Mon Sep 17 00:00:00 2001 From: czp3009 Date: Sat, 28 Jul 2018 19:29:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=8C=85?= =?UTF-8?q?=20COMBO=5FSEND=20ENTRY=5FEFFECT=20PK=5FAGAIN=20PK=5FCLICK=5FAG?= =?UTF-8?q?AIN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 +- .../bullet_screen_stream_json/COMBO_SEND.json | 11 ++ .../ENTRY_EFFECT.json | 16 ++ .../bullet_screen_stream_json/PK_AGAIN.json | 17 ++ .../PK_CLICK_AGAIN.json | 6 + .../live/socket/entity/ComboSendEntity.java | 104 +++++++++++ .../live/socket/entity/EntryEffectEntity.java | 159 ++++++++++++++++ .../api/live/socket/entity/PkAgainEntity.java | 170 ++++++++++++++++++ .../socket/entity/PkClickAgainEntity.java | 54 ++++++ .../socket/event/ComboSendPackageEvent.java | 10 ++ .../socket/event/EntryEffectPackageEvent.java | 10 ++ .../socket/event/PkAgainPackageEvent.java | 10 ++ .../event/PkClickAgainPackageEvent.java | 10 ++ .../socket/handler/LiveClientHandler.java | 19 +- 14 files changed, 602 insertions(+), 3 deletions(-) create mode 100644 record/bullet_screen_stream_json/COMBO_SEND.json create mode 100644 record/bullet_screen_stream_json/ENTRY_EFFECT.json create mode 100644 record/bullet_screen_stream_json/PK_AGAIN.json create mode 100644 record/bullet_screen_stream_json/PK_CLICK_AGAIN.json create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/entity/ComboSendEntity.java create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/entity/EntryEffectEntity.java create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkAgainEntity.java create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkClickAgainEntity.java create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/event/ComboSendPackageEvent.java create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/event/EntryEffectPackageEvent.java create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/event/PkAgainPackageEvent.java create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/event/PkClickAgainPackageEvent.java diff --git a/README.md b/README.md index 08d92e1..6a6bf42 100644 --- a/README.md +++ b/README.md @@ -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 数据包 | diff --git a/record/bullet_screen_stream_json/COMBO_SEND.json b/record/bullet_screen_stream_json/COMBO_SEND.json new file mode 100644 index 0000000..78169c0 --- /dev/null +++ b/record/bullet_screen_stream_json/COMBO_SEND.json @@ -0,0 +1,11 @@ +{ + "cmd": "COMBO_SEND", + "data": { + "uid": 33012231, + "uname": "我就是讨厌你这样", + "combo_num": 3, + "gift_name": "凉了", + "gift_id": 20010, + "action": "赠送" + } +} diff --git a/record/bullet_screen_stream_json/ENTRY_EFFECT.json b/record/bullet_screen_stream_json/ENTRY_EFFECT.json new file mode 100644 index 0000000..df1e693 --- /dev/null +++ b/record/bullet_screen_stream_json/ENTRY_EFFECT.json @@ -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" + } +} diff --git a/record/bullet_screen_stream_json/PK_AGAIN.json b/record/bullet_screen_stream_json/PK_AGAIN.json new file mode 100644 index 0000000..a9233ee --- /dev/null +++ b/record/bullet_screen_stream_json/PK_AGAIN.json @@ -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 +} diff --git a/record/bullet_screen_stream_json/PK_CLICK_AGAIN.json b/record/bullet_screen_stream_json/PK_CLICK_AGAIN.json new file mode 100644 index 0000000..8010ed5 --- /dev/null +++ b/record/bullet_screen_stream_json/PK_CLICK_AGAIN.json @@ -0,0 +1,6 @@ +{ + "pk_status": 400, + "pk_id": 60672, + "cmd": "PK_CLICK_AGAIN", + "roomid": 1489926 +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/entity/ComboSendEntity.java b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/ComboSendEntity.java new file mode 100644 index 0000000..6d1b5d0 --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/ComboSendEntity.java @@ -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; + } + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/entity/EntryEffectEntity.java b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/EntryEffectEntity.java new file mode 100644 index 0000000..4d5707e --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/EntryEffectEntity.java @@ -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; + } + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkAgainEntity.java b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkAgainEntity.java new file mode 100644 index 0000000..ab6973e --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkAgainEntity.java @@ -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; + } + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkClickAgainEntity.java b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkClickAgainEntity.java new file mode 100644 index 0000000..8940049 --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkClickAgainEntity.java @@ -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; + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/event/ComboSendPackageEvent.java b/src/main/java/com/hiczp/bilibili/api/live/socket/event/ComboSendPackageEvent.java new file mode 100644 index 0000000..ce4cc9a --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/event/ComboSendPackageEvent.java @@ -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 { + public ComboSendPackageEvent(LiveClient source, ComboSendEntity entity) { + super(source, entity); + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/event/EntryEffectPackageEvent.java b/src/main/java/com/hiczp/bilibili/api/live/socket/event/EntryEffectPackageEvent.java new file mode 100644 index 0000000..cd7525c --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/event/EntryEffectPackageEvent.java @@ -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 { + public EntryEffectPackageEvent(LiveClient source, EntryEffectEntity entity) { + super(source, entity); + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkAgainPackageEvent.java b/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkAgainPackageEvent.java new file mode 100644 index 0000000..527357e --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkAgainPackageEvent.java @@ -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 { + public PkAgainPackageEvent(LiveClient source, PkAgainEntity entity) { + super(source, entity); + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkClickAgainPackageEvent.java b/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkClickAgainPackageEvent.java new file mode 100644 index 0000000..f5b385d --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkClickAgainPackageEvent.java @@ -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 { + public PkClickAgainPackageEvent(LiveClient source, PkClickAgainEntity entity) { + super(source, entity); + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/handler/LiveClientHandler.java b/src/main/java/com/hiczp/bilibili/api/live/socket/handler/LiveClientHandler.java index 8c464a7..e10dcb5 100644 --- a/src/main/java/com/hiczp/bilibili/api/live/socket/handler/LiveClientHandler.java +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/handler/LiveClientHandler.java @@ -92,7 +92,11 @@ public class LiveClientHandler extends SimpleChannelInboundHandler { 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 { 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 { 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;