From 6e772da153d82b293f42620b14ccc695e46baee0 Mon Sep 17 00:00:00 2001 From: czp3009 Date: Thu, 28 Jun 2018 19:53:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=8C=85?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=20PK=5FMATCH,=20PK=5FPRE,=20PK=5FSTART,=20PK?= =?UTF-8?q?=5FMIC=5FEND?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +- gradle/wrapper/gradle-wrapper.properties | 3 +- .../bullet_screen_stream_json/PK_MATCH.json | 15 ++ .../bullet_screen_stream_json/PK_MIC_END.json | 8 + record/bullet_screen_stream_json/PK_PRE.json | 15 ++ .../bullet_screen_stream_json/PK_START.json | 10 ++ .../api/live/socket/entity/PkMatchEntity.java | 148 ++++++++++++++++++ .../live/socket/entity/PkMicEndEntity.java | 71 +++++++++ .../api/live/socket/entity/PkPreEntity.java | 148 ++++++++++++++++++ .../api/live/socket/entity/PkStartEntity.java | 93 +++++++++++ .../socket/event/PkMatchPackageEvent.java | 10 ++ .../socket/event/PkMicEndPackageEvent.java | 10 ++ .../live/socket/event/PkPrePackageEvent.java | 10 ++ .../socket/event/PkStartPackageEvent.java | 10 ++ .../socket/handler/LiveClientHandler.java | 17 ++ 15 files changed, 572 insertions(+), 2 deletions(-) create mode 100644 record/bullet_screen_stream_json/PK_MATCH.json create mode 100644 record/bullet_screen_stream_json/PK_MIC_END.json create mode 100644 record/bullet_screen_stream_json/PK_PRE.json create mode 100644 record/bullet_screen_stream_json/PK_START.json create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkMatchEntity.java create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkMicEndEntity.java create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkPreEntity.java create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkStartEntity.java create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/event/PkMatchPackageEvent.java create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/event/PkMicEndPackageEvent.java create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/event/PkPrePackageEvent.java create mode 100644 src/main/java/com/hiczp/bilibili/api/live/socket/event/PkStartPackageEvent.java diff --git a/README.md b/README.md index 9edcabe..6ca616c 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ # 添加依赖 ## Gradle - compile group: 'com.hiczp', name: 'bilibili-api', version: '0.0.16' + compile group: 'com.hiczp', name: 'bilibili-api', version: '0.0.17' # 名词解释 B站不少参数都是瞎取的, 并且不统一, 经常混用, 以下给出一些常见参数对应的含义 @@ -329,6 +329,10 @@ API 文档 | GuardBuyPackageEvent | 收到 GUARD_BUY 数据包 | | GuardMsgPackageEvent | 收到 GUARD_MSG 数据包 | | LivePackageEvent | 收到 LIVE 数据包 | +| PkMatchPackageEvent | 收到 PK_MATCH 数据包 | +| PkMicEndPackageEvent | 收到 PK_MIC_END 数据包 | +| PkPrePackageEvent | 收到 PK_PRE 数据包 | +| PkStartPackageEvent | 收到 PK_START 数据包 | | PreparingPackageEvent | 收到 PREPARING 数据包 | | RaffleEndPackageEvent | 收到 RAFFLE_END 数据包 | | RaffleStartPackageEvent | 收到 RAFFLE_START 数据包 | diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 933b647..c608fdc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Wed Jun 27 19:04:23 CST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/record/bullet_screen_stream_json/PK_MATCH.json b/record/bullet_screen_stream_json/PK_MATCH.json new file mode 100644 index 0000000..040a219 --- /dev/null +++ b/record/bullet_screen_stream_json/PK_MATCH.json @@ -0,0 +1,15 @@ +{ + "cmd": "PK_MATCH", + "pk_status": 100, + "pk_id": 3596, + "data": { + "init_id": 9615419, + "match_id": 10185039, + "escape_time": 5, + "is_portrait": false, + "uname": "茉莉艿", + "face": "http://i2.hdslb.com/bfs/face/3f2833a3ac598d9757ba33b79ec219cf941bdda8.jpg", + "uid": 18963076 + }, + "roomid": 9615419 +} diff --git a/record/bullet_screen_stream_json/PK_MIC_END.json b/record/bullet_screen_stream_json/PK_MIC_END.json new file mode 100644 index 0000000..88aebe2 --- /dev/null +++ b/record/bullet_screen_stream_json/PK_MIC_END.json @@ -0,0 +1,8 @@ +{ + "cmd": "PK_MIC_END", + "pk_id": 3596, + "pk_status": 1300, + "data": { + "type": 0 + } +} diff --git a/record/bullet_screen_stream_json/PK_PRE.json b/record/bullet_screen_stream_json/PK_PRE.json new file mode 100644 index 0000000..e40f3ac --- /dev/null +++ b/record/bullet_screen_stream_json/PK_PRE.json @@ -0,0 +1,15 @@ +{ + "cmd": "PK_PRE", + "pk_id": 3597, + "pk_status": 200, + "data": { + "init_id": 9615419, + "match_id": 10185039, + "count_down": 5, + "pk_topic": "模仿游戏角色让对方猜", + "pk_pre_time": 1529476609, + "pk_start_time": 1529476614, + "pk_end_time": 1529476914, + "end_time": 1529477034 + } +} diff --git a/record/bullet_screen_stream_json/PK_START.json b/record/bullet_screen_stream_json/PK_START.json new file mode 100644 index 0000000..9fa98bc --- /dev/null +++ b/record/bullet_screen_stream_json/PK_START.json @@ -0,0 +1,10 @@ +{ + "cmd": "PK_START", + "pk_id": 3597, + "pk_status": 300, + "data": { + "init_id": 9615419, + "match_id": 10185039, + "pk_topic": "模仿游戏角色让对方猜" + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkMatchEntity.java b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkMatchEntity.java new file mode 100644 index 0000000..91ba2ff --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkMatchEntity.java @@ -0,0 +1,148 @@ +package com.hiczp.bilibili.api.live.socket.entity; + +import com.google.gson.annotations.SerializedName; + +public class PkMatchEntity implements DataEntity { + /** + * cmd : PK_MATCH + * pk_status : 100 + * pk_id : 3596 + * data : {"init_id":9615419,"match_id":10185039,"escape_time":5,"is_portrait":false,"uname":"茉莉艿","face":"http://i2.hdslb.com/bfs/face/3f2833a3ac598d9757ba33b79ec219cf941bdda8.jpg","uid":18963076} + * roomid : 9615419 + */ + + @SerializedName("cmd") + private String cmd; + @SerializedName("pk_status") + private int pkStatus; + @SerializedName("pk_id") + private long pkId; + @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 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; + } + + 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 { + /** + * init_id : 9615419 + * match_id : 10185039 + * escape_time : 5 + * is_portrait : false + * uname : 茉莉艿 + * face : http://i2.hdslb.com/bfs/face/3f2833a3ac598d9757ba33b79ec219cf941bdda8.jpg + * uid : 18963076 + */ + + @SerializedName("init_id") + private long initId; + @SerializedName("match_id") + private long matchId; + @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 userId; + + 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 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 getUserId() { + return userId; + } + + public void setUserId(long userId) { + this.userId = userId; + } + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkMicEndEntity.java b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkMicEndEntity.java new file mode 100644 index 0000000..ecb09bd --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkMicEndEntity.java @@ -0,0 +1,71 @@ +package com.hiczp.bilibili.api.live.socket.entity; + +import com.google.gson.annotations.SerializedName; + +public class PkMicEndEntity implements DataEntity { + /** + * cmd : PK_MIC_END + * pk_id : 3596 + * pk_status : 1300 + * data : {"type":0} + */ + + @SerializedName("cmd") + private String cmd; + @SerializedName("pk_id") + private long pkId; + @SerializedName("pk_status") + private int pkStatus; + @SerializedName("data") + private Data data; + + @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 static class Data { + /** + * type : 0 + */ + + @SerializedName("type") + private int type; + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkPreEntity.java b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkPreEntity.java new file mode 100644 index 0000000..0d48548 --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkPreEntity.java @@ -0,0 +1,148 @@ +package com.hiczp.bilibili.api.live.socket.entity; + +import com.google.gson.annotations.SerializedName; + +public class PkPreEntity implements DataEntity { + /** + * cmd : PK_PRE + * pk_id : 3597 + * pk_status : 200 + * data : {"init_id":9615419,"match_id":10185039,"count_down":5,"pk_topic":"模仿游戏角色让对方猜","pk_pre_time":1529476609,"pk_start_time":1529476614,"pk_end_time":1529476914,"end_time":1529477034} + */ + + @SerializedName("cmd") + private String cmd; + @SerializedName("pk_id") + private long pkId; + @SerializedName("pk_status") + private int pkStatus; + @SerializedName("data") + private Data data; + + @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 static class Data { + /** + * init_id : 9615419 + * match_id : 10185039 + * count_down : 5 + * pk_topic : 模仿游戏角色让对方猜 + * pk_pre_time : 1529476609 + * pk_start_time : 1529476614 + * pk_end_time : 1529476914 + * end_time : 1529477034 + */ + + @SerializedName("init_id") + private long initId; + @SerializedName("match_id") + private long matchId; + @SerializedName("count_down") + private int countDown; + @SerializedName("pk_topic") + private String pkTopic; + @SerializedName("pk_pre_time") + private long pkPreTime; + @SerializedName("pk_start_time") + private long pkStartTime; + @SerializedName("pk_end_time") + private long pkEndTime; + @SerializedName("end_time") + private long endTime; + + 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 getCountDown() { + return countDown; + } + + public void setCountDown(int countDown) { + this.countDown = countDown; + } + + public String getPkTopic() { + return pkTopic; + } + + public void setPkTopic(String pkTopic) { + this.pkTopic = pkTopic; + } + + public long getPkPreTime() { + return pkPreTime; + } + + public void setPkPreTime(long pkPreTime) { + this.pkPreTime = pkPreTime; + } + + public long getPkStartTime() { + return pkStartTime; + } + + public void setPkStartTime(long pkStartTime) { + this.pkStartTime = pkStartTime; + } + + public long getPkEndTime() { + return pkEndTime; + } + + public void setPkEndTime(long pkEndTime) { + this.pkEndTime = pkEndTime; + } + + public long getEndTime() { + return endTime; + } + + public void setEndTime(long endTime) { + this.endTime = endTime; + } + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkStartEntity.java b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkStartEntity.java new file mode 100644 index 0000000..4755c47 --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/entity/PkStartEntity.java @@ -0,0 +1,93 @@ +package com.hiczp.bilibili.api.live.socket.entity; + +import com.google.gson.annotations.SerializedName; + +public class PkStartEntity implements DataEntity { + /** + * cmd : PK_START + * pk_id : 3597 + * pk_status : 300 + * data : {"init_id":9615419,"match_id":10185039,"pk_topic":"模仿游戏角色让对方猜"} + */ + + @SerializedName("cmd") + private String cmd; + @SerializedName("pk_id") + private long pkId; + @SerializedName("pk_status") + private int pkStatus; + @SerializedName("data") + private Data data; + + @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 static class Data { + /** + * init_id : 9615419 + * match_id : 10185039 + * pk_topic : 模仿游戏角色让对方猜 + */ + + @SerializedName("init_id") + private long initId; + @SerializedName("match_id") + private long matchId; + @SerializedName("pk_topic") + private String pkTopic; + + 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 String getPkTopic() { + return pkTopic; + } + + public void setPkTopic(String pkTopic) { + this.pkTopic = pkTopic; + } + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkMatchPackageEvent.java b/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkMatchPackageEvent.java new file mode 100644 index 0000000..ee8aa27 --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkMatchPackageEvent.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.PkMatchEntity; + +public class PkMatchPackageEvent extends ReceiveDataPackageEvent { + public PkMatchPackageEvent(LiveClient source, PkMatchEntity entity) { + super(source, entity); + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkMicEndPackageEvent.java b/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkMicEndPackageEvent.java new file mode 100644 index 0000000..dbb8648 --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkMicEndPackageEvent.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.PkMicEndEntity; + +public class PkMicEndPackageEvent extends ReceiveDataPackageEvent { + public PkMicEndPackageEvent(LiveClient source, PkMicEndEntity entity) { + super(source, entity); + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkPrePackageEvent.java b/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkPrePackageEvent.java new file mode 100644 index 0000000..a1e293c --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkPrePackageEvent.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.PkPreEntity; + +public class PkPrePackageEvent extends ReceiveDataPackageEvent { + public PkPrePackageEvent(LiveClient source, PkPreEntity entity) { + super(source, entity); + } +} diff --git a/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkStartPackageEvent.java b/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkStartPackageEvent.java new file mode 100644 index 0000000..357d10a --- /dev/null +++ b/src/main/java/com/hiczp/bilibili/api/live/socket/event/PkStartPackageEvent.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.PkStartEntity; + +public class PkStartPackageEvent extends ReceiveDataPackageEvent { + public PkStartPackageEvent(LiveClient source, PkStartEntity 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 16d3cc1..9fde273 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 @@ -111,6 +111,23 @@ public class LiveClientHandler extends SimpleChannelInboundHandler { eventCreationExpression = () -> new WelcomeGuardPackageEvent(liveClient, GSON.fromJson(jsonObject, WelcomeGuardEntity.class)); } break; + //PK + case "PK_MATCH": { + eventCreationExpression = () -> new PkMatchPackageEvent(liveClient, GSON.fromJson(jsonObject, PkMatchEntity.class)); + } + break; + case "PK_PRE": { + eventCreationExpression = () -> new PkPrePackageEvent(liveClient, GSON.fromJson(jsonObject, PkPreEntity.class)); + } + break; + case "PK_START": { + eventCreationExpression = () -> new PkStartPackageEvent(liveClient, GSON.fromJson(jsonObject, PkStartEntity.class)); + } + break; + case "PK_MIC_END": { + eventCreationExpression = () -> new PkMicEndPackageEvent(liveClient, GSON.fromJson(jsonObject, PkMicEndEntity.class)); + } + break; //系统消息(小电视等) case "SYS_MSG": { eventCreationExpression = () -> new SysMsgPackageEvent(liveClient, GSON.fromJson(jsonObject, SysMsgEntity.class));