新增 GUARD_LOTTERY_START, NOTICE_MSG, PK_INVITE_FAIL, PK_INVITE_INIT, PK_INVITE_SWITCH_CLOSE 数据包

This commit is contained in:
czp3009 2018-08-30 21:36:27 +08:00
parent 844d5a6dec
commit b637e410aa
18 changed files with 858 additions and 1 deletions

View File

@ -13,7 +13,7 @@
# 添加依赖
## Gradle
compile group: 'com.hiczp', name: 'bilibili-api', version: '0.0.19'
compile group: 'com.hiczp', name: 'bilibili-api', version: '0.0.20'
# 名词解释
B站不少参数都是瞎取的, 并且不统一, 经常混用, 以下给出一些常见参数对应的含义
@ -333,11 +333,16 @@ API 文档
| EntryEffectPackageEvent | 收到 ENTRY_EFFECT 数据包 | 尚不明确 |
| EventCmdPackageEvent | 收到 EVENT_CMD 数据包 | 尚不明确 |
| GuardBuyPackageEvent | 收到 GUARD_BUY 数据包 | 船票购买 |
| GuardLotteryStartPackageEvent | 收到 GUARD_LOTTERY_START 数据包 | 船票购买后的抽奖活动 |
| GuardMsgPackageEvent | 收到 GUARD_MSG 数据包 | 舰队消息(登船) |
| LivePackageEvent | 收到 LIVE 数据包 | 开始直播 |
| NoticeMsgPackageEvent | 收到 NOTICE_MSG 数据包 | 获得大奖的通知消息 |
| PkAgainPackageEvent | 收到 PK_AGAIN 数据包 | 下面几个都是 PK 有关的事件 |
| PkClickAgainPackageEvent | 收到 PK_CLICK_AGAIN 数据包 | |
| PkEndPackageEvent | 收到 PK_END 数据包 | |
| PkInviteFailPackageEvent | 收到 PK_INVITE_FAIL 数据包 |
| PkInviteInitPackageEvent | 收到 PK_INVITE_INIT 数据包 |
| PkInviteSwitchClosePackageEvent | 收到 PK_INVITE_SWITCH_CLOSE 数据包 |
| PkMatchPackageEvent | 收到 PK_MATCH 数据包 | |
| PkMicEndPackageEvent | 收到 PK_MIC_END 数据包 | |
| PkPrePackageEvent | 收到 PK_PRE 数据包 | |

View File

@ -0,0 +1,25 @@
{
"cmd": "GUARD_LOTTERY_START",
"data": {
"id": 396410,
"roomid": 56998,
"message": "ちゆき蝙蝠公主 在【56998】购买了舰长请前往抽奖",
"type": "guard",
"privilege_type": 3,
"link": "https://live.bilibili.com/56998",
"lottery": {
"id": 396410,
"sender": {
"uid": 11206312,
"uname": "ちゆき蝙蝠公主",
"face": "http://i0.hdslb.com/bfs/face/06d0d58131100acf13d75d3c092b1a58d41b0129.jpg"
},
"keyword": "guard",
"time": 1200,
"status": 1,
"mobile_display_mode": 2,
"mobile_static_asset": "",
"mobile_animation_asset": ""
}
}
}

View File

@ -0,0 +1,29 @@
{
"cmd": "NOTICE_MSG",
"full": {
"head_icon": "",
"is_anim": 1,
"tail_icon": "",
"background": "#33ffffff",
"color": "#33ffffff",
"highlight": "#33ffffff",
"border": "#33ffffff",
"time": 10
},
"half": {
"head_icon": "",
"is_anim": 0,
"tail_icon": "",
"background": "#33ffffff",
"color": "#33ffffff",
"highlight": "#33ffffff",
"border": "#33ffffff",
"time": 8
},
"roomid": "11415406",
"real_roomid": "0",
"msg_common": "恭喜\u003c%汤圆老师%\u003e获得大奖\u003c%23333x银瓜子%\u003e, 感谢\u003c%林发发爱林小兔%\u003e的赠送",
"msg_self": "恭喜\u003c%汤圆老师%\u003e获得大奖\u003c%23333x银瓜子%\u003e, 感谢\u003c%林发发爱林小兔%\u003e的赠送",
"link_url": "http://live.bilibili.com/0",
"msg_type": 4
}

View File

@ -0,0 +1,4 @@
{
"cmd": "PK_INVITE_FAIL",
"pk_invite_status": 1100
}

View File

@ -0,0 +1,11 @@
{
"cmd": "PK_INVITE_INIT",
"pk_invite_status": 200,
"invite_id": 408,
"face": "http://i0.hdslb.com/bfs/face/e1ad4df39e95180e990fdd565b216662bdb2503c.jpg",
"uname": "Tocci椭奇",
"area_name": "视频聊天",
"user_level": 24,
"master_level": 31,
"roomid": 883802
}

View File

@ -0,0 +1,4 @@
{
"cmd": "PK_INVITE_SWITCH_CLOSE",
"roomid": 1938890
}

View File

@ -0,0 +1,7 @@
{
"cmd": "ROOM_SHIELD",
"type": 1,
"user": "",
"keyword": "",
"roomid": 234024
}

View File

@ -0,0 +1,248 @@
package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class GuardLotteryStartEntity implements DataEntity {
/**
* cmd : GUARD_LOTTERY_START
* data : {"id":396410,"roomid":56998,"message":"ちゆき蝙蝠公主 在【56998】购买了舰长请前往抽奖","type":"guard","privilege_type":3,"link":"https://live.bilibili.com/56998","lottery":{"id":396410,"sender":{"uid":11206312,"uname":"ちゆき蝙蝠公主","face":"http://i0.hdslb.com/bfs/face/06d0d58131100acf13d75d3c092b1a58d41b0129.jpg"},"keyword":"guard","time":1200,"status":1,"mobile_display_mode":2,"mobile_static_asset":"","mobile_animation_asset":""}}
*/
@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 : 396410
* roomid : 56998
* message : ちゆき蝙蝠公主 56998购买了舰长请前往抽奖
* type : guard
* privilege_type : 3
* link : https://live.bilibili.com/56998
* lottery : {"id":396410,"sender":{"uid":11206312,"uname":"ちゆき蝙蝠公主","face":"http://i0.hdslb.com/bfs/face/06d0d58131100acf13d75d3c092b1a58d41b0129.jpg"},"keyword":"guard","time":1200,"status":1,"mobile_display_mode":2,"mobile_static_asset":"","mobile_animation_asset":""}
*/
@SerializedName("id")
private long id;
@SerializedName("roomid")
private long roomId;
@SerializedName("message")
private String message;
@SerializedName("type")
private String type;
@SerializedName("privilege_type")
private int privilegeType;
@SerializedName("link")
private String link;
@SerializedName("lottery")
private Lottery lottery;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getRoomId() {
return roomId;
}
public void setRoomId(long roomId) {
this.roomId = roomId;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public int getPrivilegeType() {
return privilegeType;
}
public void setPrivilegeType(int privilegeType) {
this.privilegeType = privilegeType;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public Lottery getLottery() {
return lottery;
}
public void setLottery(Lottery lottery) {
this.lottery = lottery;
}
public static class Lottery {
/**
* id : 396410
* sender : {"uid":11206312,"uname":"ちゆき蝙蝠公主","face":"http://i0.hdslb.com/bfs/face/06d0d58131100acf13d75d3c092b1a58d41b0129.jpg"}
* keyword : guard
* time : 1200
* status : 1
* mobile_display_mode : 2
* mobile_static_asset :
* mobile_animation_asset :
*/
@SerializedName("id")
private long id;
@SerializedName("sender")
private Sender sender;
@SerializedName("keyword")
private String keyword;
@SerializedName("time")
private int time;
@SerializedName("status")
private int status;
@SerializedName("mobile_display_mode")
private int mobileDisplayMode;
@SerializedName("mobile_static_asset")
private String mobileStaticAsset;
@SerializedName("mobile_animation_asset")
private String mobileAnimationAsset;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Sender getSender() {
return sender;
}
public void setSender(Sender sender) {
this.sender = sender;
}
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public int getMobileDisplayMode() {
return mobileDisplayMode;
}
public void setMobileDisplayMode(int mobileDisplayMode) {
this.mobileDisplayMode = mobileDisplayMode;
}
public String getMobileStaticAsset() {
return mobileStaticAsset;
}
public void setMobileStaticAsset(String mobileStaticAsset) {
this.mobileStaticAsset = mobileStaticAsset;
}
public String getMobileAnimationAsset() {
return mobileAnimationAsset;
}
public void setMobileAnimationAsset(String mobileAnimationAsset) {
this.mobileAnimationAsset = mobileAnimationAsset;
}
public static class Sender {
/**
* uid : 11206312
* uname : ちゆき蝙蝠公主
* face : http://i0.hdslb.com/bfs/face/06d0d58131100acf13d75d3c092b1a58d41b0129.jpg
*/
@SerializedName("uid")
private long userId;
@SerializedName("uname")
private String userName;
@SerializedName("face")
private String face;
public long getUserId() {
return userId;
}
public void setUserId(long userId) {
this.userId = userId;
}
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;
}
}
}
}
}

View File

@ -0,0 +1,297 @@
package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class NoticeMsgEntity implements DataEntity {
/**
* cmd : NOTICE_MSG
* full : {"head_icon":"","is_anim":1,"tail_icon":"","background":"#33ffffff","color":"#33ffffff","highlight":"#33ffffff","border":"#33ffffff","time":10}
* half : {"head_icon":"","is_anim":0,"tail_icon":"","background":"#33ffffff","color":"#33ffffff","highlight":"#33ffffff","border":"#33ffffff","time":8}
* roomid : 11415406
* real_roomid : 0
* msg_common : 恭喜<%汤圆老师%>获得大奖<%23333x银瓜子%>, 感谢<%林发发爱林小兔%>的赠送
* msg_self : 恭喜<%汤圆老师%>获得大奖<%23333x银瓜子%>, 感谢<%林发发爱林小兔%>的赠送
* link_url : http://live.bilibili.com/0
* msg_type : 4
*/
@SerializedName("cmd")
private String cmd;
@SerializedName("full")
private Full full;
@SerializedName("half")
private Half half;
@SerializedName("roomid")
private String roomId;
@SerializedName("real_roomid")
private String realRoomId;
@SerializedName("msg_common")
private String messageCommon;
@SerializedName("msg_self")
private String messageSelf;
@SerializedName("link_url")
private String linkUrl;
@SerializedName("msg_type")
private int messageType;
@Override
public String getCmd() {
return cmd;
}
public void setCmd(String cmd) {
this.cmd = cmd;
}
public Full getFull() {
return full;
}
public void setFull(Full full) {
this.full = full;
}
public Half getHalf() {
return half;
}
public void setHalf(Half half) {
this.half = half;
}
public String getRoomId() {
return roomId;
}
public void setRoomId(String roomId) {
this.roomId = roomId;
}
public String getRealRoomId() {
return realRoomId;
}
public void setRealRoomId(String realRoomId) {
this.realRoomId = realRoomId;
}
public String getMessageCommon() {
return messageCommon;
}
public void setMessageCommon(String messageCommon) {
this.messageCommon = messageCommon;
}
public String getMessageSelf() {
return messageSelf;
}
public void setMessageSelf(String messageSelf) {
this.messageSelf = messageSelf;
}
public String getLinkUrl() {
return linkUrl;
}
public void setLinkUrl(String linkUrl) {
this.linkUrl = linkUrl;
}
public int getMessageType() {
return messageType;
}
public void setMessageType(int messageType) {
this.messageType = messageType;
}
public static class Full {
/**
* head_icon :
* is_anim : 1
* tail_icon :
* background : #33ffffff
* color : #33ffffff
* highlight : #33ffffff
* border : #33ffffff
* time : 10
*/
@SerializedName("head_icon")
private String headIcon;
@SerializedName("is_anim")
private int isAnimation;
@SerializedName("tail_icon")
private String tailIcon;
@SerializedName("background")
private String background;
@SerializedName("color")
private String color;
@SerializedName("highlight")
private String highlight;
@SerializedName("border")
private String border;
@SerializedName("time")
private int time;
public String getHeadIcon() {
return headIcon;
}
public void setHeadIcon(String headIcon) {
this.headIcon = headIcon;
}
public int getIsAnimation() {
return isAnimation;
}
public void setIsAnimation(int isAnimation) {
this.isAnimation = isAnimation;
}
public String getTailIcon() {
return tailIcon;
}
public void setTailIcon(String tailIcon) {
this.tailIcon = tailIcon;
}
public String getBackground() {
return background;
}
public void setBackground(String background) {
this.background = background;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getHighlight() {
return highlight;
}
public void setHighlight(String highlight) {
this.highlight = highlight;
}
public String getBorder() {
return border;
}
public void setBorder(String border) {
this.border = border;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
}
public static class Half {
/**
* head_icon :
* is_anim : 0
* tail_icon :
* background : #33ffffff
* color : #33ffffff
* highlight : #33ffffff
* border : #33ffffff
* time : 8
*/
@SerializedName("head_icon")
private String headIcon;
@SerializedName("is_anim")
private int isAnimation;
@SerializedName("tail_icon")
private String tailIcon;
@SerializedName("background")
private String background;
@SerializedName("color")
private String color;
@SerializedName("highlight")
private String highlight;
@SerializedName("border")
private String border;
@SerializedName("time")
private int time;
public String getHeadIcon() {
return headIcon;
}
public void setHeadIcon(String headIcon) {
this.headIcon = headIcon;
}
public int getIsAnimation() {
return isAnimation;
}
public void setIsAnimation(int isAnimation) {
this.isAnimation = isAnimation;
}
public String getTailIcon() {
return tailIcon;
}
public void setTailIcon(String tailIcon) {
this.tailIcon = tailIcon;
}
public String getBackground() {
return background;
}
public void setBackground(String background) {
this.background = background;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getHighlight() {
return highlight;
}
public void setHighlight(String highlight) {
this.highlight = highlight;
}
public String getBorder() {
return border;
}
public void setBorder(String border) {
this.border = border;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
}
}

View File

@ -0,0 +1,32 @@
package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class PkInviteFailEntity implements DataEntity {
/**
* cmd : PK_INVITE_FAIL
* pk_invite_status : 1100
*/
@SerializedName("cmd")
private String cmd;
@SerializedName("pk_invite_status")
private int pkInviteStatus;
@Override
public String getCmd() {
return cmd;
}
public void setCmd(String cmd) {
this.cmd = cmd;
}
public int getPkInviteStatus() {
return pkInviteStatus;
}
public void setPkInviteStatus(int pkInviteStatus) {
this.pkInviteStatus = pkInviteStatus;
}
}

View File

@ -0,0 +1,109 @@
package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class PkInviteInitEntity implements DataEntity {
/**
* cmd : PK_INVITE_INIT
* pk_invite_status : 200
* invite_id : 408
* face : http://i0.hdslb.com/bfs/face/e1ad4df39e95180e990fdd565b216662bdb2503c.jpg
* uname : Tocci椭奇
* area_name : 视频聊天
* user_level : 24
* master_level : 31
* roomid : 883802
*/
@SerializedName("cmd")
private String cmd;
@SerializedName("pk_invite_status")
private int pkInviteStatus;
@SerializedName("invite_id")
private long inviteId;
@SerializedName("face")
private String face;
@SerializedName("uname")
private String userName;
@SerializedName("area_name")
private String areaName;
@SerializedName("user_level")
private int userLevel;
@SerializedName("master_level")
private int masterLevel;
@SerializedName("roomid")
private long roomId;
@Override
public String getCmd() {
return cmd;
}
public void setCmd(String cmd) {
this.cmd = cmd;
}
public int getPkInviteStatus() {
return pkInviteStatus;
}
public void setPkInviteStatus(int pkInviteStatus) {
this.pkInviteStatus = pkInviteStatus;
}
public long getInviteId() {
return inviteId;
}
public void setInviteId(long inviteId) {
this.inviteId = inviteId;
}
public String getFace() {
return face;
}
public void setFace(String face) {
this.face = face;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getAreaName() {
return areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public int getUserLevel() {
return userLevel;
}
public void setUserLevel(int userLevel) {
this.userLevel = userLevel;
}
public int getMasterLevel() {
return masterLevel;
}
public void setMasterLevel(int masterLevel) {
this.masterLevel = masterLevel;
}
public long getRoomId() {
return roomId;
}
public void setRoomId(long roomId) {
this.roomId = roomId;
}
}

View File

@ -0,0 +1,31 @@
package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class PkInviteSwitchCloseEntity implements DataEntity {
/**
* cmd : PK_INVITE_SWITCH_CLOSE
* roomid : 1938890
*/
@SerializedName("cmd")
private String cmd;
@SerializedName("roomid")
private long roomId;
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.GuardLotteryStartEntity;
public class GuardLotteryStartPackageEvent extends ReceiveDataPackageEvent<GuardLotteryStartEntity> {
public GuardLotteryStartPackageEvent(LiveClient source, GuardLotteryStartEntity 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.NoticeMsgEntity;
public class NoticeMsgPackageEvent extends ReceiveDataPackageEvent<NoticeMsgEntity> {
public NoticeMsgPackageEvent(LiveClient source, NoticeMsgEntity 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.PkInviteFailEntity;
public class PkInviteFailPackageEvent extends ReceiveDataPackageEvent<PkInviteFailEntity> {
public PkInviteFailPackageEvent(LiveClient source, PkInviteFailEntity 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.PkInviteInitEntity;
public class PkInviteInitPackageEvent extends ReceiveDataPackageEvent<PkInviteInitEntity> {
public PkInviteInitPackageEvent(LiveClient source, PkInviteInitEntity 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.PkInviteSwitchCloseEntity;
public class PkInviteSwitchClosePackageEvent extends ReceiveDataPackageEvent<PkInviteSwitchCloseEntity> {
public PkInviteSwitchClosePackageEvent(LiveClient source, PkInviteSwitchCloseEntity entity) {
super(source, entity);
}
}

View File

@ -38,11 +38,16 @@ public class LiveClientHandler extends SimpleChannelInboundHandler<Package> {
"ENTRY_EFFECT", EntryEffectPackageEvent.class, //TODO 尚不明确 EntryEffect 和普通 Welcome 的区别
"EVENT_CMD", EventCmdPackageEvent.class, //TODO 尚不明确 EVENT_CMD 的含义
"GUARD_BUY", GuardBuyPackageEvent.class, //船票购买
"GUARD_LOTTERY_START", GuardLotteryStartPackageEvent.class, //船票购买后的抽奖活动
"GUARD_MSG", GuardMsgPackageEvent.class, //舰队消息(登船)
"LIVE", LivePackageEvent.class, //开始直播
"NOTICE_MSG", NoticeMsgPackageEvent.class, //获得大奖的通知消息
"PK_AGAIN", PkAgainPackageEvent.class, //PK
"PK_CLICK_AGAIN", PkClickAgainPackageEvent.class,
"PK_END", PkEndPackageEvent.class,
"PK_INVITE_FAIL", PkInviteFailPackageEvent.class,
"PK_INVITE_INIT", PkInviteInitPackageEvent.class,
"PK_INVITE_SWITCH_CLOSE", PkInviteSwitchClosePackageEvent.class,
"PK_MATCH", PkMatchPackageEvent.class,
"PK_MIC_END", PkMicEndPackageEvent.class,
"PK_PRE", PkPrePackageEvent.class,