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

This commit is contained in:
czp 2018-03-13 23:16:39 +08:00
parent 084f0e0863
commit cde9cee03d
6 changed files with 121 additions and 2 deletions

View File

@ -326,6 +326,8 @@ API 文档
| GuardMsgPackageEvent | 收到 GUARD_MSG 数据包 |
| LivePackageEvent | 收到 LIVE 数据包 |
| PreparingPackageEvent | 收到 PREPARING 数据包 |
| RaffleEndPackageEvent | 收到 RAFFLE_END 数据包 |
| RaffleStartPackageEvent | 收到 RAFFLE_START 数据包 |
| ReceiveDataPackageDebugEvent | 该事件用于调试, 收到任何 Data 数据包时都会触发 |
| RoomAdminsPackageEvent | 收到 ROOM_ADMINS 数据包 |
| RoomBlockMsgPackageEvent | 收到 ROOM_BLOCK_MSG 数据包 |

View File

@ -0,0 +1,10 @@
{
"cmd": "RAFFLE_START",
"roomid": 234024,
"data": {
"raffleId": 16915,
"type": "flower_rain",
"from": "爱吃喵姐的鱼",
"time": 60
}
}

View File

@ -16,6 +16,7 @@ public class RaffleEndEntity implements DataEntity {
@SerializedName("data")
private Data data;
@Override
public String getCmd() {
return cmd;
}

View File

@ -0,0 +1,93 @@
package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class RaffleStartEntity implements DataEntity {
/**
* cmd : RAFFLE_START
* roomid : 234024
* data : {"raffleId":16915,"type":"flower_rain","from":"爱吃喵姐的鱼","time":60}
*/
@SerializedName("cmd")
private String cmd;
@SerializedName("roomid")
private int roomid;
@SerializedName("data")
private Data data;
@Override
public String getCmd() {
return cmd;
}
public void setCmd(String cmd) {
this.cmd = cmd;
}
public int getRoomid() {
return roomid;
}
public void setRoomid(int roomid) {
this.roomid = roomid;
}
public Data getData() {
return data;
}
public void setData(Data data) {
this.data = data;
}
public static class Data {
/**
* raffleId : 16915
* type : flower_rain
* from : 爱吃喵姐的鱼
* time : 60
*/
@SerializedName("raffleId")
private int raffleId;
@SerializedName("type")
private String type;
@SerializedName("from")
private String from;
@SerializedName("time")
private int time;
public int getRaffleId() {
return raffleId;
}
public void setRaffleId(int raffleId) {
this.raffleId = raffleId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
}
}

View File

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

View File

@ -124,8 +124,12 @@ public class LiveClientHandler extends SimpleChannelInboundHandler<Package> {
eventCreationExpression = () -> new SpecialGiftPackageEvent(this, GSON.fromJson(jsonObject, SpecialGiftEntity.class));
}
break;
//TODO RAFFLE_START
//抽奖结束(小奖, 通常是不定期活动)
//抽奖开始(小奖, 通常是不定期活动)
case "RAFFLE_START": {
eventCreationExpression = () -> new RaffleStartPackageEvent(this, GSON.fromJson(jsonObject, RaffleStartEntity.class));
}
break;
//抽奖
case "RAFFLE_END": {
eventCreationExpression = () -> new RaffleEndPackageEvent(this, GSON.fromJson(jsonObject, RaffleEndEntity.class));
}