为直播间弹幕推送有关的数据包实体设计接口以方便编程

This commit is contained in:
czp 2018-02-23 22:41:53 +08:00
parent 5f2f753b0f
commit f83edb1a96
15 changed files with 40 additions and 13 deletions

View File

@ -2,7 +2,7 @@ package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class ActivityEventEntity {
public class ActivityEventEntity implements DataEntity {
/**
* cmd : ACTIVITY_EVENT
* data : {"keyword":"newspring_2018","type":"cracker","limit":300000,"progress":158912}
@ -13,6 +13,7 @@ public class ActivityEventEntity {
@SerializedName("data")
private Data data;
@Override
public String getCmd() {
return cmd;
}

View File

@ -9,7 +9,7 @@ import java.lang.reflect.Type;
import java.util.List;
import java.util.Optional;
public class DanMuMsgEntity {
public class DanMuMsgEntity implements DataEntity {
private static final Gson GSON = new Gson();
private static final Type STRING_LIST_TYPE = new TypeToken<List<String>>() {
}.getType();
@ -24,6 +24,7 @@ public class DanMuMsgEntity {
@SerializedName("info")
private JsonArray info;
@Override
public String getCmd() {
return cmd;
}

View File

@ -0,0 +1,5 @@
package com.hiczp.bilibili.api.live.socket.entity;
public interface DataEntity {
String getCmd();
}

View File

@ -2,7 +2,7 @@ package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class GuardMsgEntity {
public class GuardMsgEntity implements DataEntity {
/**
* cmd : GUARD_MSG
* msg : 乘客 :?想不想joice:? 成功购买1313366房间总督船票1张欢迎登船
@ -13,6 +13,7 @@ public class GuardMsgEntity {
@SerializedName("msg")
private String msg;
@Override
public String getCmd() {
return cmd;
}

View File

@ -2,7 +2,7 @@ package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class LiveEntity {
public class LiveEntity implements RoomStatusEntity {
/**
* cmd : LIVE
* roomid : 1110317
@ -13,6 +13,7 @@ public class LiveEntity {
@SerializedName("roomid")
private String roomId;
@Override
public String getCmd() {
return cmd;
}
@ -21,6 +22,7 @@ public class LiveEntity {
this.cmd = cmd;
}
@Override
public String getRoomId() {
return roomId;
}

View File

@ -2,7 +2,7 @@ package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class PreparingEntity {
public class PreparingEntity implements RoomStatusEntity {
/**
* cmd : PREPARING
* roomid : 1110317
@ -13,6 +13,7 @@ public class PreparingEntity {
@SerializedName("roomid")
private String roomId;
@Override
public String getCmd() {
return cmd;
}
@ -21,6 +22,7 @@ public class PreparingEntity {
this.cmd = cmd;
}
@Override
public String getRoomId() {
return roomId;
}

View File

@ -2,7 +2,7 @@ package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class RoomBlockMsgEntity {
public class RoomBlockMsgEntity implements DataEntity {
/**
* cmd : ROOM_BLOCK_MSG
* uid : 60244207
@ -19,6 +19,7 @@ public class RoomBlockMsgEntity {
@SerializedName("roomid")
private long roomid;
@Override
public String getCmd() {
return cmd;
}

View File

@ -4,7 +4,7 @@ import com.google.gson.annotations.SerializedName;
import java.util.List;
public class RoomSilentOffEntity {
public class RoomSilentOffEntity implements DataEntity {
/**
* cmd : ROOM_SILENT_OFF
* data : []
@ -18,6 +18,7 @@ public class RoomSilentOffEntity {
@SerializedName("data")
private List<?> data;
@Override
public String getCmd() {
return cmd;
}

View File

@ -0,0 +1,7 @@
package com.hiczp.bilibili.api.live.socket.entity;
public interface RoomStatusEntity {
String getCmd();
String getRoomId();
}

View File

@ -6,7 +6,7 @@ import com.google.gson.annotations.SerializedName;
import java.util.List;
public class SendGiftEntity {
public class SendGiftEntity implements DataEntity {
/**
* cmd : SEND_GIFT
* data : {"giftName":"辣条","num":64,"uname":"明暗纠结星","rcost":66347035,"uid":12768615,"top_list":[{"uid":9256,"userName":"SSR","coin":2905900,"face":"http://i0.hdslb.com/bfs/face/eba52abb1daaf3aecd7b986b9731451872d66613.jpg","guard_level":"3","rank":1,"score":2905900},{"uid":4986301,"userName":"乄夏沫丶","coin":1386000,"face":"http://i2.hdslb.com/bfs/face/b3969027a263d2610711317addf437fe59a9b97e.jpg","guard_level":0,"rank":2,"score":1386000},{"uid":5211302,"userName":"朝雾怜","coin":805700,"face":"http://i1.hdslb.com/bfs/face/d366be69d716469514d355642aa324ceba3fa122.jpg","guard_level":0,"rank":3,"score":805700}],"timestamp":1510498496,"giftId":1,"giftType":0,"action":"喂食","super":0,"price":100,"rnd":"1510498460","newMedal":0,"newTitle":0,"medal":[],"title":"","beatId":"0","biz_source":"live","metadata":"","remain":0,"gold":0,"silver":0,"eventScore":0,"eventNum":0,"smalltv_msg":[],"notice_msg":[],"capsule":{"normal":{"coin":13,"change":1,"progress":{"now":4000,"max":10000}},"colorful":{"coin":0,"change":0,"progress":{"now":0,"max":5000}}},"addFollow":0}
@ -17,6 +17,7 @@ public class SendGiftEntity {
@SerializedName("data")
private DataEntity data;
@Override
public String getCmd() {
return cmd;
}

View File

@ -2,7 +2,7 @@ package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class SysGiftEntity {
public class SysGiftEntity implements DataEntity {
/**
* cmd : SYS_GIFT
* msg : あさひなみよう在直播间5135178开启了丰收祭典一起来分享收获的福利吧
@ -34,6 +34,7 @@ public class SysGiftEntity {
@SerializedName("msgTips")
private int msgTips;
@Override
public String getCmd() {
return cmd;
}

View File

@ -2,7 +2,7 @@ package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class SysMsgEntity {
public class SysMsgEntity implements DataEntity {
/**
* cmd : SYS_MSG
* msg : 瑾然-:?在直播间:?3939852:?赠送 小电视一个请前往抽奖
@ -38,6 +38,7 @@ public class SysMsgEntity {
@SerializedName("tv_id")
private String tvId;
@Override
public String getCmd() {
return cmd;
}

View File

@ -2,7 +2,7 @@ package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class WelcomeEntity {
public class WelcomeEntity implements DataEntity {
/**
* cmd : WELCOME
* data : {"uid":516505,"uname":"圣蝎","is_admin":false,"vip":1}
@ -13,6 +13,7 @@ public class WelcomeEntity {
@SerializedName("data")
private DataEntity data;
@Override
public String getCmd() {
return cmd;
}

View File

@ -2,7 +2,7 @@ package com.hiczp.bilibili.api.live.socket.entity;
import com.google.gson.annotations.SerializedName;
public class WelcomeGuardEntity {
public class WelcomeGuardEntity implements DataEntity {
/**
* cmd : WELCOME_GUARD
* data : {"uid":23598108,"username":"lovevael","guard_level":3,"water_god":0}
@ -16,6 +16,7 @@ public class WelcomeGuardEntity {
@SerializedName("roomid")
private long roomId;
@Override
public String getCmd() {
return cmd;
}

View File

@ -4,7 +4,7 @@ import com.google.gson.annotations.SerializedName;
import java.util.List;
public class WishBottleEntity {
public class WishBottleEntity implements DataEntity {
/**
* cmd : WISH_BOTTLE
* data : {"action":"update","id":1832,"wish":{"id":1832,"uid":110631,"type":1,"type_id":7,"wish_limit":99999,"wish_progress":14381,"status":1,"content":"女装直播","ctime":"2018-01-12 17:25:58","count_map":[1,3,5]}}
@ -15,6 +15,7 @@ public class WishBottleEntity {
@SerializedName("data")
private Data data;
@Override
public String getCmd() {
return cmd;
}