增加弹幕推送数据包类型 SPECIAL_GIFT

This commit is contained in:
czp 2018-03-08 17:00:29 +08:00
parent 49c639effa
commit 9bdaa584ce
5 changed files with 173 additions and 14 deletions

View File

@ -0,0 +1,14 @@
{
"cmd": "SPECIAL_GIFT",
"data": {
"39": {
"id": 202090,
"time": 90,
"hadJoin": 0,
"num": 1,
"content": "月轮来袭",
"action": "start",
"storm_gif": "http://static.hdslb.com/live-static/live-room/images/gift-section/mobilegift/2/jiezou.gif?2017011901"
}
}
}

View File

@ -55,7 +55,6 @@ public interface LiveService {
Call<TitlesEntity> getTitle();
//TODO 节奏风暴
//这个 API 不是很明确, 似乎和 节奏风暴 有关系
@GET("SpecialGift/room/{roomId}")
Call<SpecialGiftEntity> getSpecialGift(@Path("roomId") long roomId);

View File

@ -0,0 +1,132 @@
package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class SpecialGiftEntity implements DataEntity {
/**
* cmd : SPECIAL_GIFT
* data : {"39":{"id":202090,"time":90,"hadJoin":0,"num":1,"content":"月轮来袭","action":"start","storm_gif":"http://static.hdslb.com/live-static/live-room/images/gift-section/mobilegift/2/jiezou.gif?2017011901"}}
*/
@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 {
/**
* 39 : {"id":202090,"time":90,"hadJoin":0,"num":1,"content":"月轮来袭","action":"start","storm_gif":"http://static.hdslb.com/live-static/live-room/images/gift-section/mobilegift/2/jiezou.gif?2017011901"}
*/
@SerializedName("39")
private _$39 $39;
public _$39 get$39() {
return $39;
}
public void set$39(_$39 $39) {
this.$39 = $39;
}
public static class _$39 {
/**
* id : 202090
* time : 90
* hadJoin : 0
* num : 1
* content : 月轮来袭
* action : start
* storm_gif : http://static.hdslb.com/live-static/live-room/images/gift-section/mobilegift/2/jiezou.gif?2017011901
*/
@SerializedName("id")
private long id;
@SerializedName("time")
private int time;
@SerializedName("hadJoin")
private int hadJoin;
@SerializedName("num")
private int num;
@SerializedName("content")
private String content;
@SerializedName("action")
private String action;
@SerializedName("storm_gif")
private String stormGif;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
public int getHadJoin() {
return hadJoin;
}
public void setHadJoin(int hadJoin) {
this.hadJoin = hadJoin;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getStormGif() {
return stormGif;
}
public void setStormGif(String stormGif) {
this.stormGif = stormGif;
}
}
}
}

View File

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

View File

@ -117,21 +117,15 @@ public class LiveClientHandler extends SimpleChannelInboundHandler<Package> {
eventCreationExpression = () -> new WelcomeGuardPackageEvent(this, GSON.fromJson(content, WelcomeGuardEntity.class));
}
break;
//开始直播
case "LIVE": {
eventCreationExpression = () -> new LivePackageEvent(this, GSON.fromJson(content, LiveEntity.class));
}
break;
//停止直播
case "PREPARING": {
eventCreationExpression = () -> new PreparingPackageEvent(this, GSON.fromJson(content, PreparingEntity.class));
}
break;
//活动事件
case "ACTIVITY_EVENT": {
eventCreationExpression = () -> new ActivityEventPackageEvent(this, GSON.fromJson(content, ActivityEventEntity.class));
}
break;
case "SPECIAL_GIFT": {
eventCreationExpression = () -> new SpecialGiftPackageEvent(this, GSON.fromJson(content, SpecialGiftEntity.class));
}
break;
//许愿瓶
case "WISH_BOTTLE": {
eventCreationExpression = () -> new WishBottlePackageEvent(this, GSON.fromJson(content, WishBottleEntity.class));
@ -162,14 +156,25 @@ public class LiveClientHandler extends SimpleChannelInboundHandler<Package> {
eventCreationExpression = () -> new GuardMsgPackageEvent(this, GSON.fromJson(content, GuardMsgEntity.class));
}
break;
//TODO TV_START
//小电视抽奖结束(大奖的获得者信息)
case "TV_END": {
eventCreationExpression = () -> new TVEndPackageEvent(this, GSON.fromJson(content, TVEndEntity.class));
}
break;
//房管变更
case "ROOM_ADMINS": {
eventCreationExpression = () -> new RoomAdminsPackageEvent(this, GSON.fromJson(content, RoomAdminsEntity.class));
}
break;
//小电视抽奖结束(大奖的获得者信息)
case "TV_END": {
eventCreationExpression = () -> new TVEndPackageEvent(this, GSON.fromJson(content, TVEndEntity.class));
//开始直播
case "LIVE": {
eventCreationExpression = () -> new LivePackageEvent(this, GSON.fromJson(content, LiveEntity.class));
}
break;
//停止直播
case "PREPARING": {
eventCreationExpression = () -> new PreparingPackageEvent(this, GSON.fromJson(content, PreparingEntity.class));
}
break;
default: {