增加弹幕推送流的数据包类型 EVENT_CMD

This commit is contained in:
czp 2018-03-13 23:23:31 +08:00
parent cde9cee03d
commit 4b4ee68cfc
5 changed files with 93 additions and 0 deletions

View File

@ -322,6 +322,7 @@ API 文档
| ConnectionCloseEvent | 连接断开(主动或被动) |
| ConnectSucceedEvent | 进房成功 |
| DanMuMsgPackageEvent | 收到 DANMU_MSG 数据包 |
| EventCmdPackageEvent | 收到 EVENT_CMD 数据包 |
| GuardBuyPackageEvent | 收到 GUARD_BUY 数据包 |
| GuardMsgPackageEvent | 收到 GUARD_MSG 数据包 |
| LivePackageEvent | 收到 LIVE 数据包 |

View File

@ -0,0 +1,8 @@
{
"roomid": 234024,
"cmd": "EVENT_CMD",
"data": {
"event_type": "flower_rain-16915",
"event_img": "http://s1.hdslb.com/bfs/static/blive/live-assets/mobile/activity/lover_2018/raffle.png"
}
}

View File

@ -0,0 +1,71 @@
package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class EventCmdEntity implements DataEntity {
/**
* roomid : 234024
* cmd : EVENT_CMD
* data : {"event_type":"flower_rain-16915","event_img":"http://s1.hdslb.com/bfs/static/blive/live-assets/mobile/activity/lover_2018/raffle.png"}
*/
@SerializedName("roomid")
private long roomid;
@SerializedName("cmd")
private String cmd;
@SerializedName("data")
private Data data;
public long getRoomid() {
return roomid;
}
public void setRoomid(long roomid) {
this.roomid = roomid;
}
@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 {
/**
* event_type : flower_rain-16915
* event_img : http://s1.hdslb.com/bfs/static/blive/live-assets/mobile/activity/lover_2018/raffle.png
*/
@SerializedName("event_type")
private String eventType;
@SerializedName("event_img")
private String eventImg;
public String getEventType() {
return eventType;
}
public void setEventType(String eventType) {
this.eventType = eventType;
}
public String getEventImg() {
return eventImg;
}
public void setEventImg(String eventImg) {
this.eventImg = eventImg;
}
}
}

View File

@ -0,0 +1,9 @@
package com.hiczp.bilibili.api.live.socket.event;
import com.hiczp.bilibili.api.live.socket.entity.EventCmdEntity;
public class EventCmdPackageEvent extends ReceiveDataPackageEvent<EventCmdEntity> {
public EventCmdPackageEvent(Object source, EventCmdEntity entity) {
super(source, entity);
}
}

View File

@ -134,6 +134,10 @@ public class LiveClientHandler extends SimpleChannelInboundHandler<Package> {
eventCreationExpression = () -> new RaffleEndPackageEvent(this, GSON.fromJson(jsonObject, RaffleEndEntity.class));
}
break;
case "EVENT_CMD": {
eventCreationExpression = () -> new EventCmdPackageEvent(this, GSON.fromJson(jsonObject, EventCmdEntity.class));
}
break;
//房间黑名单(添加了一个用户到黑名单)
case "ROOM_BLOCK_MSG": {
eventCreationExpression = () -> new RoomBlockMsgPackageEvent(this, GSON.fromJson(jsonObject, RoomBlockMsgEntity.class));