优化代码

This commit is contained in:
czp3009 2018-07-31 19:26:19 +08:00
parent f010aa77ef
commit d08d1fbd8c
32 changed files with 320 additions and 454 deletions

View File

@ -28,6 +28,9 @@ B站不少参数都是瞎取的, 并且不统一, 经常混用, 以下给出一
| roomId | 直播间的真实 ID(直播房间号在 1000 以下的房间, 真实 ID 是另外一个数字) | | roomId | 直播间的真实 ID(直播房间号在 1000 以下的房间, 真实 ID 是另外一个数字) |
| cid | 直播间 ID(URL 上的短房间号以及真实房间号都叫 cid) | | cid | 直播间 ID(URL 上的短房间号以及真实房间号都叫 cid) |
| ruid | 直播间房主的用户 ID | | ruid | 直播间房主的用户 ID |
| rcost | 该房间内消费的瓜子数量 |
(上表仅供其他开发者参照, 本调用库中已经封装为 Java 标准全写小驼峰命名法, 例如 userId, roomId, roomUserId)
# 使用 # 使用
## RESTFul API ## RESTFul API
@ -317,54 +320,54 @@ API 文档
所有的事件(有些数据包我也不知道它里面的一些值是什么含义, /record 目录下面有抓取到的 Json, 可以用来查看): 所有的事件(有些数据包我也不知道它里面的一些值是什么含义, /record 目录下面有抓取到的 Json, 可以用来查看):
| 事件 | 抛出条件 | | 事件 | 抛出条件 | 含义 |
| :--- | :--- | | :--- | :--- | :--- |
| ActivityEventPackageEvent | 收到 ACTIVITY_EVENT 数据包 | | ActivityEventPackageEvent | 收到 ACTIVITY_EVENT 数据包 | 活动事件 |
| ChangeRoomInfoPackageEvent | 收到 CHANGE_ROOM_INFO 数据包 | | ChangeRoomInfoPackageEvent | 收到 CHANGE_ROOM_INFO 数据包 | 更换房间背景图片 |
| ComboEndPackageEvent | 收到 COMBO_END 数据包 | | ComboEndPackageEvent | 收到 COMBO_END 数据包 | 礼物连发结束 |
| ComboSendPackageEvent | 收到 COMBO_SEND 数据包 | | ComboSendPackageEvent | 收到 COMBO_SEND 数据包 | 礼物连发开始 |
| ConnectionCloseEvent | 连接断开(主动或被动) | | ConnectionCloseEvent | 连接断开(主动或被动) | |
| ConnectSucceedEvent | 进房成功 | | ConnectSucceedEvent | 进房成功 | |
| CutOffPackageEvent | 收到 CUT_OFF 数据包 | | CutOffPackageEvent | 收到 CUT_OFF 数据包 | 被 B站 管理员强制中断 |
| DanMuMsgPackageEvent | 收到 DANMU_MSG 数据包 | | DanMuMsgPackageEvent | 收到 DANMU_MSG 数据包 | 弹幕消息 |
| EntryEffectPackageEvent | 收到 ENTRY_EFFECT 数据包 | | EntryEffectPackageEvent | 收到 ENTRY_EFFECT 数据包 | 尚不明确 |
| EventCmdPackageEvent | 收到 EVENT_CMD 数据包 | | EventCmdPackageEvent | 收到 EVENT_CMD 数据包 | 尚不明确 |
| GuardBuyPackageEvent | 收到 GUARD_BUY 数据包 | | GuardBuyPackageEvent | 收到 GUARD_BUY 数据包 | 船票购买 |
| GuardMsgPackageEvent | 收到 GUARD_MSG 数据包 | | GuardMsgPackageEvent | 收到 GUARD_MSG 数据包 | 舰队消息(登船) |
| LivePackageEvent | 收到 LIVE 数据包 | | LivePackageEvent | 收到 LIVE 数据包 | 开始直播 |
| PkAgainPackageEvent | 收到 PK_AGAIN 数据包 | | PkAgainPackageEvent | 收到 PK_AGAIN 数据包 | 下面几个都是 PK 有关的事件 |
| PkClickAgainPackageEvent | 收到 PK_CLICK_AGAIN 数据包 | | PkClickAgainPackageEvent | 收到 PK_CLICK_AGAIN 数据包 | |
| PkEndPackageEvent | 收到 PK_END 数据包 | | PkEndPackageEvent | 收到 PK_END 数据包 | |
| PkMatchPackageEvent | 收到 PK_MATCH 数据包 | | PkMatchPackageEvent | 收到 PK_MATCH 数据包 | |
| PkMicEndPackageEvent | 收到 PK_MIC_END 数据包 | | PkMicEndPackageEvent | 收到 PK_MIC_END 数据包 | |
| PkPrePackageEvent | 收到 PK_PRE 数据包 | | PkPrePackageEvent | 收到 PK_PRE 数据包 | |
| PkProcessPackageEvent | 收到 PK_PROCESS 数据包 | | PkProcessPackageEvent | 收到 PK_PROCESS 数据包 | |
| PkSettlePackageEvent | 收到 PK_SETTLE 数据包 | | PkSettlePackageEvent | 收到 PK_SETTLE 数据包 | |
| PkStartPackageEvent | 收到 PK_START 数据包 | | PkStartPackageEvent | 收到 PK_START 数据包 | |
| PreparingPackageEvent | 收到 PREPARING 数据包 | | PreparingPackageEvent | 收到 PREPARING 数据包 | 停止直播 |
| RaffleEndPackageEvent | 收到 RAFFLE_END 数据包 | | RaffleEndPackageEvent | 收到 RAFFLE_END 数据包 | 抽奖结束(小奖, 通常是不定期活动) |
| RaffleStartPackageEvent | 收到 RAFFLE_START 数据包 | | RaffleStartPackageEvent | 收到 RAFFLE_START 数据包 | 抽奖开始(小奖) |
| ReceiveDataPackageDebugEvent | 该事件用于调试, 收到任何 Data 数据包时都会触发 | | ReceiveDataPackageDebugEvent | 该事件用于调试, 收到任何 Data 数据包时都会触发 | |
| RoomAdminsPackageEvent | 收到 ROOM_ADMINS 数据包 | | RoomAdminsPackageEvent | 收到 ROOM_ADMINS 数据包 | 房管变更 |
| RoomBlockMsgPackageEvent | 收到 ROOM_BLOCK_MSG 数据包 | | RoomBlockMsgPackageEvent | 收到 ROOM_BLOCK_MSG 数据包 | 房间黑名单(房间管理员添加了一个用户到黑名单) |
| RoomLockPackageEvent | 收到 ROOM_LOCK 数据包 | | RoomLockPackageEvent | 收到 ROOM_LOCK 数据包 | 房间被封 |
| RoomRankPackageEvent | 收到 ROOM_RANK 数据包 | | RoomRankPackageEvent | 收到 ROOM_RANK 数据包 | 小时榜 |
| RoomShieldPackageEvent | 收到 ROOM_SHIELD 数据包 | | RoomShieldPackageEvent | 收到 ROOM_SHIELD 数据包 | 房间屏蔽 |
| RoomSilentOffPackageEvent | 收到 ROOM_SILENT_OFF 数据包 | | RoomSilentOffPackageEvent | 收到 ROOM_SILENT_OFF 数据包 | 房间结束禁言 |
| RoomSilentOnPackageEvent | 收到 ROOM_SILENT_ON 数据包 | | RoomSilentOnPackageEvent | 收到 ROOM_SILENT_ON 数据包 | 房间开启了禁言(禁止某一等级以下的用户发言) |
| SendGiftPackageEvent | 收到 SEND_GIFT 数据包 | | SendGiftPackageEvent | 收到 SEND_GIFT 数据包 | 送礼 |
| SendHeartBeatPackageEvent | 每次发送心跳包后触发一次 | | SendHeartBeatPackageEvent | 每次发送心跳包后触发一次 | |
| SpecialGiftPackageEvent | 收到 SPECIAL_GIFT 数据包 | | SpecialGiftPackageEvent | 收到 SPECIAL_GIFT 数据包 | 节奏风暴(20 倍以下的)(只在对应房间内有, 不会全站广播) |
| SysGiftPackageEvent | 收到 SYS_GIFT 数据包 | | SysGiftPackageEvent | 收到 SYS_GIFT 数据包 | 系统礼物(20 倍以上节奏风暴, 活动抽奖等) |
| SysMsgPackageEvent | 收到 SYS_MSG 数据包 | | SysMsgPackageEvent | 收到 SYS_MSG 数据包 | 系统消息(小电视等) |
| TVEndPackageEvent | 收到 TV_END 数据包 | | TVEndPackageEvent | 收到 TV_END 数据包 | 小电视抽奖结束(大奖的获得者信息) |
| TVStartPackageEvent | 收到 TV_START 数据包 | | TVStartPackageEvent | 收到 TV_START 数据包 | 小电视抽奖开始 |
| UnknownPackageEvent | B站新增了新种类的数据包, 出现此情况请提交 issue | | UnknownPackageEvent | B站新增了新种类的数据包, 出现此情况请提交 issue | |
| ViewerCountPackageEvent | 收到 房间人数 数据包(不是 Json) | | ViewerCountPackageEvent | 收到 房间人数 数据包(不是 Json) | |
| WelcomeActivityPackageEvent | 收到 WELCOME_ACTIVITY 数据包 | | WelcomePackageEvent | 收到 WELCOME 数据包 | 欢迎(通常是 VIP) |
| WelcomeGuardPackageEvent | 收到 WELCOME_GUARD 数据包 | | WelcomeActivityPackageEvent | 收到 WELCOME_ACTIVITY 数据包 | 欢迎(活动) |
| WelcomePackageEvent | 收到 WELCOME 数据包 | | WelcomeGuardPackageEvent | 收到 WELCOME_GUARD 数据包 | 欢迎(舰队) |
| WishBottlePackageEvent | 收到 WISH_BOTTLE 数据包 | | WishBottlePackageEvent | 收到 WISH_BOTTLE 数据包 | 许愿瓶 |
事件里面可以取到解析好的 POJO, 然后可以从里面取数据, 见上面的监听器示例. 事件里面可以取到解析好的 POJO, 然后可以从里面取数据, 见上面的监听器示例.

View File

@ -204,8 +204,8 @@ public interface LiveService {
/** /**
* 发送一条弹幕 * 发送一条弹幕
* *
* @param cid 房间号 * @param roomId 房间号
* @param mid 自己的用户 ID * @param userId 自己的用户 ID
* @param message 内容 * @param message 内容
* @param random 随机数 * @param random 随机数
* @param mode 弹幕模式 * @param mode 弹幕模式
@ -218,8 +218,8 @@ public interface LiveService {
*/ */
@POST("api/sendmsg") @POST("api/sendmsg")
@FormUrlEncoded @FormUrlEncoded
Call<SendBulletScreenResponseEntity> sendBulletScreen(@Field("cid") long cid, Call<SendBulletScreenResponseEntity> sendBulletScreen(@Field("cid") long roomId,
@Field("mid") long mid, @Field("mid") long userId,
@Field("msg") String message, @Field("msg") String message,
@Field("rnd") long random, @Field("rnd") long random,
@Field("mode") int mode, @Field("mode") int mode,
@ -236,8 +236,8 @@ public interface LiveService {
*/ */
default Call<SendBulletScreenResponseEntity> sendBulletScreen(BulletScreenEntity bulletScreenEntity) { default Call<SendBulletScreenResponseEntity> sendBulletScreen(BulletScreenEntity bulletScreenEntity) {
return sendBulletScreen( return sendBulletScreen(
bulletScreenEntity.getCid(), bulletScreenEntity.getRoomId(),
bulletScreenEntity.getMid(), bulletScreenEntity.getUserId(),
bulletScreenEntity.getMessage(), bulletScreenEntity.getMessage(),
bulletScreenEntity.getRandom(), bulletScreenEntity.getRandom(),
bulletScreenEntity.getMode(), bulletScreenEntity.getMode(),

View File

@ -54,7 +54,7 @@ public class ActivityGiftsEntity extends ResponseEntity {
@SerializedName("name") @SerializedName("name")
private String name; private String name;
@SerializedName("num") @SerializedName("num")
private int num; private int number;
@SerializedName("img") @SerializedName("img")
private String img; private String img;
@SerializedName("gift_url") @SerializedName("gift_url")
@ -92,12 +92,12 @@ public class ActivityGiftsEntity extends ResponseEntity {
this.name = name; this.name = name;
} }
public int getNum() { public int getNumber() {
return num; return number;
} }
public void setNum(int num) { public void setNumber(int number) {
this.num = num; this.number = number;
} }
public String getImg() { public String getImg() {

View File

@ -1075,7 +1075,7 @@ public class AllListEntity extends ResponseEntity {
@SerializedName("face") @SerializedName("face")
private String face; private String face;
@SerializedName("mid") @SerializedName("mid")
private int mid; private long userId;
@SerializedName("name") @SerializedName("name")
private String name; private String name;
@ -1087,12 +1087,12 @@ public class AllListEntity extends ResponseEntity {
this.face = face; this.face = face;
} }
public int getMid() { public long getUserId() {
return mid; return userId;
} }
public void setMid(int mid) { public void setUserId(long userId) {
this.mid = mid; this.userId = userId;
} }
public String getName() { public String getName() {

View File

@ -69,7 +69,7 @@ public class AssistantRoomInfoEntity extends ResponseEntity {
@SerializedName("uname") @SerializedName("uname")
private String username; private String username;
@SerializedName("rcost") @SerializedName("rcost")
private int rcost; private int roomCost;
@SerializedName("online") @SerializedName("online")
private int online; private int online;
@SerializedName("status") @SerializedName("status")
@ -141,12 +141,12 @@ public class AssistantRoomInfoEntity extends ResponseEntity {
this.username = username; this.username = username;
} }
public int getRcost() { public int getRoomCost() {
return rcost; return roomCost;
} }
public void setRcost(int rcost) { public void setRoomCost(int roomCost) {
this.rcost = rcost; this.roomCost = roomCost;
} }
public int getOnline() { public int getOnline() {

View File

@ -95,7 +95,7 @@ public class AwardsEntity extends ResponseEntity {
@SerializedName("id") @SerializedName("id")
private int id; private int id;
@SerializedName("uid") @SerializedName("uid")
private int uid; private long userId;
@SerializedName("gift_name") @SerializedName("gift_name")
private String giftName; private String giftName;
@SerializedName("gift_type") @SerializedName("gift_type")
@ -137,12 +137,12 @@ public class AwardsEntity extends ResponseEntity {
this.id = id; this.id = id;
} }
public int getUid() { public long getUserId() {
return uid; return userId;
} }
public void setUid(int uid) { public void setUserId(long userId) {
this.uid = uid; this.userId = userId;
} }
public String getGiftName() { public String getGiftName() {

View File

@ -3,9 +3,11 @@ package com.hiczp.bilibili.api.live.entity;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
public class BulletScreenEntity { public class BulletScreenEntity {
private long cid; @SerializedName("cid")
private long roomId;
private long mid; @SerializedName("mid")
private long userId;
/** /**
* 弹幕长度限制为 LiveRoomInfoEntity.getData().getMsgLength(), 对于每个用户而言, 每个房间都一样 * 弹幕长度限制为 LiveRoomInfoEntity.getData().getMsgLength(), 对于每个用户而言, 每个房间都一样
@ -50,27 +52,27 @@ public class BulletScreenEntity {
/** /**
* 实际上并不需要包含 mid 就可以正常发送弹幕, 但是真实的 Android 客户端确实发送了 mid * 实际上并不需要包含 mid 就可以正常发送弹幕, 但是真实的 Android 客户端确实发送了 mid
*/ */
public BulletScreenEntity(long cid, long mid, String message) { public BulletScreenEntity(long roomId, long userId, String message) {
this.cid = cid; this.roomId = roomId;
this.mid = mid; this.userId = userId;
this.message = message; this.message = message;
} }
public long getCid() { public long getRoomId() {
return cid; return roomId;
} }
public BulletScreenEntity setCid(long cid) { public BulletScreenEntity setRoomId(long roomId) {
this.cid = cid; this.roomId = roomId;
return this; return this;
} }
public long getMid() { public long getUserId() {
return mid; return userId;
} }
public BulletScreenEntity setMid(long mid) { public BulletScreenEntity setUserId(long userId) {
this.mid = mid; this.userId = userId;
return this; return this;
} }

View File

@ -45,7 +45,7 @@ public class GiftEntity {
} }
public GiftEntity(long giftId, long bagId, long number, LiveRoomInfoEntity.LiveRoom liveRoom) { public GiftEntity(long giftId, long bagId, long number, LiveRoomInfoEntity.LiveRoom liveRoom) {
this(giftId, bagId, number, liveRoom.getRoomId(), liveRoom.getMid()); this(giftId, bagId, number, liveRoom.getRoomId(), liveRoom.getUserId());
} }
public GiftEntity(PlayerBagEntity.BagGift bagGift, long number, long roomId, long roomUserId) { public GiftEntity(PlayerBagEntity.BagGift bagGift, long number, long roomId, long roomUserId) {
@ -53,7 +53,7 @@ public class GiftEntity {
} }
public GiftEntity(PlayerBagEntity.BagGift bagGift, long number, LiveRoomInfoEntity.LiveRoom liveRoom) { public GiftEntity(PlayerBagEntity.BagGift bagGift, long number, LiveRoomInfoEntity.LiveRoom liveRoom) {
this(bagGift.getGiftId(), bagGift.getId(), number, liveRoom.getRoomId(), liveRoom.getMid()); this(bagGift.getGiftId(), bagGift.getId(), number, liveRoom.getRoomId(), liveRoom.getUserId());
} }
public long getGiftId() { public long getGiftId() {

View File

@ -105,7 +105,7 @@ public class GiftTopEntity extends ResponseEntity {
*/ */
@SerializedName("uid") @SerializedName("uid")
private int uid; private long userId;
@SerializedName("rank") @SerializedName("rank")
private int rank; private int rank;
@SerializedName("isSelf") @SerializedName("isSelf")
@ -121,12 +121,12 @@ public class GiftTopEntity extends ResponseEntity {
@SerializedName("guard_level") @SerializedName("guard_level")
private int guardLevel; private int guardLevel;
public int getUid() { public long getUserId() {
return uid; return userId;
} }
public void setUid(int uid) { public void setUserId(long userId) {
this.uid = uid; this.userId = userId;
} }
public int getRank() { public int getRank() {

View File

@ -77,7 +77,7 @@ public class LiveHistoryBulletScreensEntity extends ResponseEntity {
@SerializedName("text") @SerializedName("text")
private String text; private String text;
@SerializedName("uid") @SerializedName("uid")
private int uid; private long userId;
@SerializedName("nickname") @SerializedName("nickname")
private String nickname; private String nickname;
@SerializedName("timeline") @SerializedName("timeline")
@ -113,12 +113,12 @@ public class LiveHistoryBulletScreensEntity extends ResponseEntity {
this.text = text; this.text = text;
} }
public int getUid() { public long getUserId() {
return uid; return userId;
} }
public void setUid(int uid) { public void setUserId(long userId) {
this.uid = uid; this.userId = userId;
} }
public String getNickname() { public String getNickname() {

View File

@ -96,13 +96,13 @@ public class LiveRoomInfoEntity extends ResponseEntity {
@SerializedName("cover") @SerializedName("cover")
private String cover; private String cover;
@SerializedName("mid") @SerializedName("mid")
private long mid; private long userId;
@SerializedName("uname") @SerializedName("uname")
private String username; private String username;
@SerializedName("face") @SerializedName("face")
private String face; private String face;
@SerializedName("m_face") @SerializedName("m_face")
private String mFace; private String mobileFace;
@SerializedName("background_id") @SerializedName("background_id")
private int backgroundId; private int backgroundId;
@SerializedName("attention") @SerializedName("attention")
@ -116,7 +116,7 @@ public class LiveRoomInfoEntity extends ResponseEntity {
@SerializedName("create_at") @SerializedName("create_at")
private String createAt; private String createAt;
@SerializedName("sch_id") @SerializedName("sch_id")
private int schId; private int scheduleId;
@SerializedName("status") @SerializedName("status")
private String status; private String status;
@SerializedName("area") @SerializedName("area")
@ -218,12 +218,12 @@ public class LiveRoomInfoEntity extends ResponseEntity {
this.cover = cover; this.cover = cover;
} }
public long getMid() { public long getUserId() {
return mid; return userId;
} }
public void setMid(long mid) { public void setUserId(long userId) {
this.mid = mid; this.userId = userId;
} }
public String getUsername() { public String getUsername() {
@ -242,12 +242,12 @@ public class LiveRoomInfoEntity extends ResponseEntity {
this.face = face; this.face = face;
} }
public String getMFace() { public String getMobileFace() {
return mFace; return mobileFace;
} }
public void setMFace(String mFace) { public void setMobileFace(String mobileFace) {
this.mFace = mFace; this.mobileFace = mobileFace;
} }
public int getBackgroundId() { public int getBackgroundId() {
@ -298,12 +298,12 @@ public class LiveRoomInfoEntity extends ResponseEntity {
this.createAt = createAt; this.createAt = createAt;
} }
public int getSchId() { public int getScheduleId() {
return schId; return scheduleId;
} }
public void setSchId(int schId) { public void setScheduleId(int scheduleId) {
this.schId = schId; this.scheduleId = scheduleId;
} }
public String getStatus() { public String getStatus() {
@ -630,11 +630,11 @@ public class LiveRoomInfoEntity extends ResponseEntity {
@SerializedName("cid") @SerializedName("cid")
private long cid; private long cid;
@SerializedName("sch_id") @SerializedName("sch_id")
private int schId; private int scheduleId;
@SerializedName("title") @SerializedName("title")
private String title; private String title;
@SerializedName("mid") @SerializedName("mid")
private long mid; private long userId;
@SerializedName("start") @SerializedName("start")
private long start; private long start;
@SerializedName("start_at") @SerializedName("start_at")
@ -662,12 +662,12 @@ public class LiveRoomInfoEntity extends ResponseEntity {
this.cid = cid; this.cid = cid;
} }
public int getSchId() { public int getScheduleId() {
return schId; return scheduleId;
} }
public void setSchId(int schId) { public void setScheduleId(int scheduleId) {
this.schId = schId; this.scheduleId = scheduleId;
} }
public String getTitle() { public String getTitle() {
@ -678,12 +678,12 @@ public class LiveRoomInfoEntity extends ResponseEntity {
this.title = title; this.title = title;
} }
public long getMid() { public long getUserId() {
return mid; return userId;
} }
public void setMid(long mid) { public void setUserId(long userId) {
this.mid = mid; this.userId = userId;
} }
public long getStart() { public long getStart() {
@ -941,7 +941,7 @@ public class LiveRoomInfoEntity extends ResponseEntity {
@SerializedName("face") @SerializedName("face")
private String face; private String face;
@SerializedName("mid") @SerializedName("mid")
private int mid; private long userId;
@SerializedName("name") @SerializedName("name")
private String name; private String name;
@ -953,12 +953,12 @@ public class LiveRoomInfoEntity extends ResponseEntity {
this.face = face; this.face = face;
} }
public int getMid() { public long getUserId() {
return mid; return userId;
} }
public void setMid(int mid) { public void setUserId(long userId) {
this.mid = mid; this.userId = userId;
} }
public String getName() { public String getName() {

View File

@ -59,7 +59,7 @@ public class MyTitleListEntity extends ResponseEntity {
*/ */
@SerializedName("uid") @SerializedName("uid")
private int uid; private long userId;
@SerializedName("had") @SerializedName("had")
private boolean had; private boolean had;
@SerializedName("title") @SerializedName("title")
@ -77,12 +77,12 @@ public class MyTitleListEntity extends ResponseEntity {
@SerializedName("category") @SerializedName("category")
private List<Category> category; private List<Category> category;
public int getUid() { public long getUserId() {
return uid; return userId;
} }
public void setUid(int uid) { public void setUserId(long userId) {
this.uid = uid; this.userId = userId;
} }
public boolean isHad() { public boolean isHad() {

View File

@ -130,7 +130,7 @@ public class OpenCapsuleResponseEntity extends ResponseEntity {
@SerializedName("name") @SerializedName("name")
private String name; private String name;
@SerializedName("num") @SerializedName("num")
private String num; private String number;
@SerializedName("img") @SerializedName("img")
private String img; private String img;
@ -142,12 +142,12 @@ public class OpenCapsuleResponseEntity extends ResponseEntity {
this.name = name; this.name = name;
} }
public String getNum() { public String getNumber() {
return num; return number;
} }
public void setNum(String num) { public void setNumber(String number) {
this.num = num; this.number = number;
} }
public String getImg() { public String getImg() {

View File

@ -53,7 +53,7 @@ public class PlayerBagEntity extends ResponseEntity {
@SerializedName("id") @SerializedName("id")
private long id; private long id;
@SerializedName("uid") @SerializedName("uid")
private long uid; private long userId;
@SerializedName("gift_id") @SerializedName("gift_id")
private long giftId; private long giftId;
@SerializedName("gift_num") @SerializedName("gift_num")
@ -85,12 +85,12 @@ public class PlayerBagEntity extends ResponseEntity {
this.id = id; this.id = id;
} }
public long getUid() { public long getUserId() {
return uid; return userId;
} }
public void setUid(long uid) { public void setUserId(long userId) {
this.uid = uid; this.userId = userId;
} }
public long getGiftId() { public long getGiftId() {

View File

@ -578,7 +578,7 @@ public class RecommendRoomRefreshResponseEntity extends ResponseEntity {
@SerializedName("face") @SerializedName("face")
private String face; private String face;
@SerializedName("mid") @SerializedName("mid")
private int mid; private long userId;
@SerializedName("name") @SerializedName("name")
private String name; private String name;
@ -590,12 +590,12 @@ public class RecommendRoomRefreshResponseEntity extends ResponseEntity {
this.face = face; this.face = face;
} }
public int getMid() { public long getUserId() {
return mid; return userId;
} }
public void setMid(int mid) { public void setUserId(long userId) {
this.mid = mid; this.userId = userId;
} }
public String getName() { public String getName() {

View File

@ -125,7 +125,7 @@ public class SendGiftResponseEntity extends ResponseEntity {
@SerializedName("uname") @SerializedName("uname")
private String username; private String username;
@SerializedName("rcost") @SerializedName("rcost")
private int rcost; private int roomCost;
@SerializedName("uid") @SerializedName("uid")
private int uid; private int uid;
@SerializedName("timestamp") @SerializedName("timestamp")
@ -206,12 +206,12 @@ public class SendGiftResponseEntity extends ResponseEntity {
this.username = username; this.username = username;
} }
public int getRcost() { public int getRoomCost() {
return rcost; return roomCost;
} }
public void setRcost(int rcost) { public void setRoomCost(int roomCost) {
this.rcost = rcost; this.roomCost = roomCost;
} }
public int getUid() { public int getUid() {

View File

@ -171,7 +171,7 @@ public class UserTasksEntity extends ResponseEntity {
@SerializedName("type") @SerializedName("type")
private String type; private String type;
@SerializedName("num") @SerializedName("num")
private int num; private int number;
public String getName() { public String getName() {
return name; return name;
@ -189,12 +189,12 @@ public class UserTasksEntity extends ResponseEntity {
this.type = type; this.type = type;
} }
public int getNum() { public int getNumber() {
return num; return number;
} }
public void setNum(int num) { public void setNumber(int number) {
this.num = num; this.number = number;
} }
} }
} }
@ -288,7 +288,7 @@ public class UserTasksEntity extends ResponseEntity {
@SerializedName("type") @SerializedName("type")
private String type; private String type;
@SerializedName("num") @SerializedName("num")
private int num; private int number;
public String getName() { public String getName() {
return name; return name;
@ -306,12 +306,12 @@ public class UserTasksEntity extends ResponseEntity {
this.type = type; this.type = type;
} }
public int getNum() { public int getNumber() {
return num; return number;
} }
public void setNum(int num) { public void setNumber(int number) {
this.num = num; this.number = number;
} }
} }
} }
@ -427,7 +427,7 @@ public class UserTasksEntity extends ResponseEntity {
@SerializedName("type") @SerializedName("type")
private String type; private String type;
@SerializedName("num") @SerializedName("num")
private int num; private int number;
public String getName() { public String getName() {
return name; return name;
@ -445,12 +445,12 @@ public class UserTasksEntity extends ResponseEntity {
this.type = type; this.type = type;
} }
public int getNum() { public int getNumber() {
return num; return number;
} }
public void setNum(int num) { public void setNumber(int number) {
this.num = num; this.number = number;
} }
} }
} }

View File

@ -58,7 +58,7 @@ public class WearTitleEntity extends ResponseEntity {
@SerializedName("tid") @SerializedName("tid")
private String tid; private String tid;
@SerializedName("num") @SerializedName("num")
private String num; private String number;
@SerializedName("score") @SerializedName("score")
private String score; private String score;
@SerializedName("create_time") @SerializedName("create_time")
@ -104,12 +104,12 @@ public class WearTitleEntity extends ResponseEntity {
this.tid = tid; this.tid = tid;
} }
public String getNum() { public String getNumber() {
return num; return number;
} }
public void setNum(String num) { public void setNumber(String number) {
this.num = num; this.number = number;
} }
public String getScore() { public String getScore() {

View File

@ -38,9 +38,9 @@ public class LiveClient {
private final BilibiliServiceProvider bilibiliServiceProvider; private final BilibiliServiceProvider bilibiliServiceProvider;
private final EventLoopGroup eventLoopGroup; private final EventLoopGroup eventLoopGroup;
private final long userId; private final long userId;
private final EventBus eventBus = new EventBus("BilibiliLiveClientEventBus");
private Long showRoomId; private Long showRoomId;
private Long realRoomId; private Long realRoomId;
private final EventBus eventBus;
private boolean useRealRoomIdForConstructing; private boolean useRealRoomIdForConstructing;
private LiveRoomInfoEntity.LiveRoom liveRoom; private LiveRoomInfoEntity.LiveRoom liveRoom;
@ -57,6 +57,7 @@ public class LiveClient {
showRoomId = roomId; showRoomId = roomId;
} }
this.userId = userId; this.userId = userId;
this.eventBus = new EventBus(String.format("BilibiliLiveClientEventBus-%s", getShowRoomIdOrRoomId()));
} }
public LiveClient(@Nonnull BilibiliServiceProvider bilibiliServiceProvider, @Nonnull EventLoopGroup eventLoopGroup, long showRoomId, long userId) { public LiveClient(@Nonnull BilibiliServiceProvider bilibiliServiceProvider, @Nonnull EventLoopGroup eventLoopGroup, long showRoomId, long userId) {

View File

@ -50,20 +50,20 @@ public class GuardBuyEntity implements DataEntity {
*/ */
@SerializedName("uid") @SerializedName("uid")
private int uid; private long userId;
@SerializedName("username") @SerializedName("username")
private String username; private String username;
@SerializedName("guard_level") @SerializedName("guard_level")
private int guardLevel; private int guardLevel;
@SerializedName("num") @SerializedName("num")
private int num; private int number;
public int getUid() { public long getUserId() {
return uid; return userId;
} }
public void setUid(int uid) { public void setUserId(long userId) {
this.uid = uid; this.userId = userId;
} }
public String getUsername() { public String getUsername() {
@ -82,12 +82,12 @@ public class GuardBuyEntity implements DataEntity {
this.guardLevel = guardLevel; this.guardLevel = guardLevel;
} }
public int getNum() { public int getNumber() {
return num; return number;
} }
public void setNum(int num) { public void setNumber(int number) {
this.num = num; this.number = number;
} }
} }
} }

View File

@ -72,7 +72,7 @@ public class PkProcessEntity implements DataEntity {
*/ */
@SerializedName("uid") @SerializedName("uid")
private int userId; private long userId;
@SerializedName("init_votes") @SerializedName("init_votes")
private int initVotes; private int initVotes;
@SerializedName("match_votes") @SerializedName("match_votes")
@ -80,11 +80,11 @@ public class PkProcessEntity implements DataEntity {
@SerializedName("user_votes") @SerializedName("user_votes")
private int userVotes; private int userVotes;
public int getUserId() { public long getUserId() {
return userId; return userId;
} }
public void setUserId(int userId) { public void setUserId(long userId) {
this.userId = userId; this.userId = userId;
} }

View File

@ -13,7 +13,7 @@ public class RoomBlockMsgEntity implements DataEntity {
@SerializedName("cmd") @SerializedName("cmd")
private String cmd; private String cmd;
@SerializedName("uid") @SerializedName("uid")
private String uid; private String userId;
@SerializedName("uname") @SerializedName("uname")
private String username; private String username;
@SerializedName("roomid") @SerializedName("roomid")
@ -28,12 +28,12 @@ public class RoomBlockMsgEntity implements DataEntity {
this.cmd = cmd; this.cmd = cmd;
} }
public String getUid() { public String getUserId() {
return uid; return userId;
} }
public void setUid(String uid) { public void setUserId(String userId) {
this.uid = uid; this.userId = userId;
} }
public String getUsername() { public String getUsername() {

View File

@ -73,13 +73,13 @@ public class SendGiftEntity implements DataEntity {
@SerializedName("giftName") @SerializedName("giftName")
private String giftName; private String giftName;
@SerializedName("num") @SerializedName("num")
private int num; private int number;
@SerializedName("uname") @SerializedName("uname")
private String username; private String username;
@SerializedName("rcost") @SerializedName("rcost")
private int rcost; private int roomCost;
@SerializedName("uid") @SerializedName("uid")
private long uid; private long userId;
@SerializedName("timestamp") @SerializedName("timestamp")
private long timestamp; private long timestamp;
@SerializedName("giftId") @SerializedName("giftId")
@ -156,12 +156,12 @@ public class SendGiftEntity implements DataEntity {
this.giftName = giftName; this.giftName = giftName;
} }
public int getNum() { public int getNumber() {
return num; return number;
} }
public void setNum(int num) { public void setNumber(int number) {
this.num = num; this.number = number;
} }
public String getUsername() { public String getUsername() {
@ -172,20 +172,20 @@ public class SendGiftEntity implements DataEntity {
this.username = username; this.username = username;
} }
public int getRcost() { public int getRoomCost() {
return rcost; return roomCost;
} }
public void setRcost(int rcost) { public void setRoomCost(int roomCost) {
this.rcost = rcost; this.roomCost = roomCost;
} }
public long getUid() { public long getUserId() {
return uid; return userId;
} }
public void setUid(long uid) { public void setUserId(long userId) {
this.uid = uid; this.userId = userId;
} }
public long getTimestamp() { public long getTimestamp() {
@ -477,7 +477,7 @@ public class SendGiftEntity implements DataEntity {
@SerializedName("hadJoin") @SerializedName("hadJoin")
private int hadJoin; private int hadJoin;
@SerializedName("num") @SerializedName("num")
private int num; private int number;
@SerializedName("content") @SerializedName("content")
private String content; private String content;
@SerializedName("action") @SerializedName("action")
@ -509,12 +509,12 @@ public class SendGiftEntity implements DataEntity {
this.hadJoin = hadJoin; this.hadJoin = hadJoin;
} }
public int getNum() { public int getNumber() {
return num; return number;
} }
public void setNum(int num) { public void setNumber(int number) {
this.num = num; this.number = number;
} }
public String getContent() { public String getContent() {
@ -727,7 +727,7 @@ public class SendGiftEntity implements DataEntity {
*/ */
@SerializedName("uid") @SerializedName("uid")
private int uid; private long userId;
@SerializedName("uname") @SerializedName("uname")
private String username; private String username;
@SerializedName("face") @SerializedName("face")
@ -741,12 +741,12 @@ public class SendGiftEntity implements DataEntity {
@SerializedName("isSelf") @SerializedName("isSelf")
private int isSelf; private int isSelf;
public int getUid() { public long getUserId() {
return uid; return userId;
} }
public void setUid(int uid) { public void setUserId(long userId) {
this.uid = uid; this.userId = userId;
} }
public String getUsername() { public String getUsername() {

View File

@ -39,7 +39,7 @@ public class WelcomeActivityEntity implements DataEntity {
*/ */
@SerializedName("uid") @SerializedName("uid")
private long uid; private long userId;
@SerializedName("uname") @SerializedName("uname")
private String username; private String username;
@SerializedName("type") @SerializedName("type")
@ -47,12 +47,12 @@ public class WelcomeActivityEntity implements DataEntity {
@SerializedName("display_mode") @SerializedName("display_mode")
private int displayMode; private int displayMode;
public long getUid() { public long getUserId() {
return uid; return userId;
} }
public void setUid(long uid) { public void setUserId(long userId) {
this.uid = uid; this.userId = userId;
} }
public String getUsername() { public String getUsername() {

View File

@ -50,7 +50,7 @@ public class WelcomeGuardEntity implements DataEntity {
*/ */
@SerializedName("uid") @SerializedName("uid")
private int uid; private long userId;
@SerializedName("username") @SerializedName("username")
private String username; private String username;
@SerializedName("guard_level") @SerializedName("guard_level")
@ -58,12 +58,12 @@ public class WelcomeGuardEntity implements DataEntity {
@SerializedName("water_god") @SerializedName("water_god")
private Integer waterGod; private Integer waterGod;
public int getUid() { public long getUserId() {
return uid; return userId;
} }
public void setUid(int uid) { public void setUserId(long userId) {
this.uid = uid; this.userId = userId;
} }
public String getUsername() { public String getUsername() {

View File

@ -87,7 +87,7 @@ public class WishBottleEntity implements DataEntity {
@SerializedName("id") @SerializedName("id")
private long id; private long id;
@SerializedName("uid") @SerializedName("uid")
private long uid; private long userId;
@SerializedName("type") @SerializedName("type")
private int type; private int type;
@SerializedName("type_id") @SerializedName("type_id")
@ -113,12 +113,12 @@ public class WishBottleEntity implements DataEntity {
this.id = id; this.id = id;
} }
public long getUid() { public long getUserId() {
return uid; return userId;
} }
public void setUid(long uid) { public void setUserId(long userId) {
this.uid = uid; this.userId = userId;
} }
public int getType() { public int getType() {

View File

@ -19,6 +19,8 @@ import java.io.InputStreamReader;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class LiveClientHandler extends SimpleChannelInboundHandler<Package> { public class LiveClientHandler extends SimpleChannelInboundHandler<Package> {
@ -26,6 +28,56 @@ public class LiveClientHandler extends SimpleChannelInboundHandler<Package> {
private static final Gson GSON = new Gson(); private static final Gson GSON = new Gson();
private static final Gson PRETTY_PRINTING_GSON = new GsonBuilder().setPrettyPrinting().create(); private static final Gson PRETTY_PRINTING_GSON = new GsonBuilder().setPrettyPrinting().create();
private static final JsonParser JSON_PARSER = new JsonParser(); private static final JsonParser JSON_PARSER = new JsonParser();
private static final Object[] CMD_AND_EVENT_ARRAY = new Object[]{
"ACTIVITY_EVENT", ActivityEventPackageEvent.class, //活动事件
"CHANGE_ROOM_INFO", ChangeRoomInfoPackageEvent.class, //更换房间背景图片
"COMBO_END", ComboEndPackageEvent.class, //COMBO
"COMBO_SEND", ComboSendPackageEvent.class,
"CUT_OFF", CutOffPackageEvent.class, // B站 管理员强制中断
"DANMU_MSG", DanMuMsgPackageEvent.class, //弹幕消息
"ENTRY_EFFECT", EntryEffectPackageEvent.class, //TODO 尚不明确 EntryEffect 和普通 Welcome 的区别
"EVENT_CMD", EventCmdPackageEvent.class, //TODO 尚不明确 EVENT_CMD 的含义
"GUARD_BUY", GuardBuyPackageEvent.class, //船票购买
"GUARD_MSG", GuardMsgPackageEvent.class, //舰队消息(登船)
"LIVE", LivePackageEvent.class, //开始直播
"PK_AGAIN", PkAgainPackageEvent.class, //PK
"PK_CLICK_AGAIN", PkClickAgainPackageEvent.class,
"PK_END", PkEndPackageEvent.class,
"PK_MATCH", PkMatchPackageEvent.class,
"PK_MIC_END", PkMicEndPackageEvent.class,
"PK_PRE", PkPrePackageEvent.class,
"PK_PROCESS", PkProcessPackageEvent.class,
"PK_SETTLE", PkSettlePackageEvent.class,
"PK_START", PkStartPackageEvent.class,
"PREPARING", PreparingPackageEvent.class, //停止直播
"RAFFLE_END", RaffleEndPackageEvent.class, //抽奖结束
"RAFFLE_START", RaffleStartPackageEvent.class, //抽奖开始(小奖, 通常是不定期活动)
"ROOM_ADMINS", RoomAdminsPackageEvent.class, //房管变更
"ROOM_BLOCK_MSG", RoomBlockMsgPackageEvent.class, //房间黑名单(房间管理员添加了一个用户到黑名单)
"ROOM_LOCK", RoomLockPackageEvent.class, //房间被封
"ROOM_RANK", RoomRankPackageEvent.class, //小时榜
"ROOM_SHIELD", RoomShieldPackageEvent.class, //房间屏蔽
"ROOM_SILENT_OFF", RoomSilentOffPackageEvent.class, //房间结束禁言
"ROOM_SILENT_ON", RoomSilentOnPackageEvent.class, //房间开启了禁言(禁止某一等级以下的用户发言)
"SEND_GIFT", SendGiftPackageEvent.class, //送礼
"SPECIAL_GIFT", SpecialGiftPackageEvent.class, //节奏风暴(20 倍以下的)
"SYS_GIFT", SysGiftPackageEvent.class, //系统礼物(节奏风暴, 活动抽奖等)
"SYS_MSG", SysMsgPackageEvent.class, //系统消息(小电视等)
"TV_END", TVEndPackageEvent.class, //小电视抽奖结束(大奖的获得者信息)
"TV_START", TVStartPackageEvent.class, //小电视抽奖开始
"WELCOME", WelcomePackageEvent.class, //欢迎(通常是 VIP)
"WELCOME_ACTIVITY", WelcomeActivityPackageEvent.class, //欢迎(活动)
"WELCOME_GUARD", WelcomeGuardPackageEvent.class, //欢迎(舰队)
"WISH_BOTTLE", WishBottlePackageEvent.class //许愿瓶
};
private static final Map<String, Class<? extends ReceiveDataPackageEvent>> EVENT_MAP = new HashMap<>();
static {
for (int i = 0; i < CMD_AND_EVENT_ARRAY.length; i += 2) {
//noinspection unchecked
EVENT_MAP.put((String) CMD_AND_EVENT_ARRAY[i], (Class<? extends ReceiveDataPackageEvent>) CMD_AND_EVENT_ARRAY[i + 1]);
}
}
private final LiveClient liveClient; private final LiveClient liveClient;
private final EventBus eventBus; private final EventBus eventBus;
@ -79,201 +131,9 @@ public class LiveClientHandler extends SimpleChannelInboundHandler<Package> {
e.printStackTrace(); e.printStackTrace();
break; break;
} }
eventBus.post(new ReceiveDataPackageDebugEvent(liveClient, jsonObject, cmd)); eventBus.post(new ReceiveDataPackageDebugEvent(liveClient, jsonObject, cmd)); //debug
Class<? extends ReceiveDataPackageEvent> eventType = null;
switch (cmd) { Class<? extends ReceiveDataPackageEvent> eventType = EVENT_MAP.get(cmd);
//弹幕消息
case "DANMU_MSG": {
eventType = DanMuMsgPackageEvent.class;
}
break;
//送礼
case "SEND_GIFT": {
eventType = SendGiftPackageEvent.class;
}
break;
//combo
case "COMBO_SEND": {
eventType = ComboSendPackageEvent.class;
}
break;
case "COMBO_END": {
eventType = ComboEndPackageEvent.class;
}
break;
//欢迎
case "WELCOME": {
eventType = WelcomePackageEvent.class;
}
break;
//许愿瓶
case "WISH_BOTTLE": {
eventType = WishBottlePackageEvent.class;
}
break;
//欢迎(舰队)
case "WELCOME_GUARD": {
eventType = WelcomeGuardPackageEvent.class;
}
break;
//TODO 尚不明确 EntryEffect 和普通 Welcome 的区别
case "ENTRY_EFFECT": {
eventType = EntryEffectPackageEvent.class;
}
break;
//PK
case "PK_MATCH": {
eventType = PkMatchPackageEvent.class;
}
break;
case "PK_PRE": {
eventType = PkPrePackageEvent.class;
}
break;
case "PK_START": {
eventType = PkStartPackageEvent.class;
}
break;
case "PK_PROCESS": {
eventType = PkProcessPackageEvent.class;
}
break;
case "PK_END": {
eventType = PkEndPackageEvent.class;
}
break;
case "PK_MIC_END": {
eventType = PkMicEndPackageEvent.class;
}
break;
case "PK_SETTLE": {
eventType = PkSettlePackageEvent.class;
}
break;
case "PK_AGAIN": {
eventType = PkAgainPackageEvent.class;
}
break;
case "PK_CLICK_AGAIN": {
eventType = PkClickAgainPackageEvent.class;
}
break;
//系统消息(小电视等)
case "SYS_MSG": {
eventType = SysMsgPackageEvent.class;
}
break;
//系统礼物(节奏风暴, 活动抽奖等)
case "SYS_GIFT": {
eventType = SysGiftPackageEvent.class;
}
break;
//活动事件
case "ACTIVITY_EVENT": {
eventType = ActivityEventPackageEvent.class;
}
break;
//节奏风暴(20 倍以下的)
case "SPECIAL_GIFT": {
eventType = SpecialGiftPackageEvent.class;
}
break;
//抽奖开始(小奖, 通常是不定期活动)
case "RAFFLE_START": {
eventType = RaffleStartPackageEvent.class;
}
break;
//抽奖结束
case "RAFFLE_END": {
eventType = RaffleEndPackageEvent.class;
}
break;
//TODO 尚不明确 EVENT_CMD 的含义
case "EVENT_CMD": {
eventType = EventCmdPackageEvent.class;
}
break;
//房间黑名单(房间管理员添加了一个用户到黑名单)
case "ROOM_BLOCK_MSG": {
eventType = RoomBlockMsgPackageEvent.class;
}
break;
//房间开启了禁言(禁止某一等级以下的用户发言)
case "ROOM_SILENT_ON": {
eventType = RoomSilentOnPackageEvent.class;
}
break;
//房间结束禁言
case "ROOM_SILENT_OFF": {
eventType = RoomSilentOffPackageEvent.class;
}
break;
//船票购买
case "GUARD_BUY": {
eventType = GuardBuyPackageEvent.class;
}
break;
//舰队消息(登船)
case "GUARD_MSG": {
eventType = GuardMsgPackageEvent.class;
}
break;
//小电视抽奖开始
case "TV_START": {
eventType = TVStartPackageEvent.class;
}
break;
//小电视抽奖结束(大奖的获得者信息)
case "TV_END": {
eventType = TVEndPackageEvent.class;
}
break;
//小时榜
case "ROOM_RANK": {
eventType = RoomRankPackageEvent.class;
}
break;
//欢迎(活动)
case "WELCOME_ACTIVITY": {
eventType = WelcomeActivityPackageEvent.class;
}
break;
//房管变更
case "ROOM_ADMINS": {
eventType = RoomAdminsPackageEvent.class;
}
break;
//开始直播
case "LIVE": {
eventType = LivePackageEvent.class;
}
break;
//停止直播
case "PREPARING": {
eventType = PreparingPackageEvent.class;
}
break;
//房间屏蔽
case "ROOM_SHIELD": {
eventType = RoomShieldPackageEvent.class;
}
break;
//更换房间背景图片
case "CHANGE_ROOM_INFO": {
eventType = ChangeRoomInfoPackageEvent.class;
}
break;
// B站 管理员强制中断
case "CUT_OFF": {
eventType = CutOffPackageEvent.class;
}
break;
//房间被封
case "ROOM_LOCK": {
eventType = RoomLockPackageEvent.class;
}
break;
}
//UnknownPackage //UnknownPackage
if (eventType == null) { if (eventType == null) {

View File

@ -51,7 +51,7 @@ public class InfoEntity extends ResponseEntity {
*/ */
@SerializedName("mid") @SerializedName("mid")
private long mid; private long userId;
@SerializedName("appid") @SerializedName("appid")
private int appId; private int appId;
@SerializedName("access_token") @SerializedName("access_token")
@ -59,16 +59,16 @@ public class InfoEntity extends ResponseEntity {
@SerializedName("expires_in") @SerializedName("expires_in")
private long expiresIn; private long expiresIn;
@SerializedName("userid") @SerializedName("userid")
private String userId; private String userIdString;
@SerializedName("uname") @SerializedName("uname")
private String username; private String username;
public long getMid() { public long getUserId() {
return mid; return userId;
} }
public void setMid(long mid) { public void setUserId(long userId) {
this.mid = mid; this.userId = userId;
} }
public int getAppId() { public int getAppId() {
@ -95,12 +95,12 @@ public class InfoEntity extends ResponseEntity {
this.expiresIn = expiresIn; this.expiresIn = expiresIn;
} }
public String getUserId() { public String getUserIdString() {
return userId; return userIdString;
} }
public void setUserId(String userId) { public void setUserIdString(String userIdString) {
this.userId = userId; this.userIdString = userIdString;
} }
public String getUsername() { public String getUsername() {

View File

@ -45,7 +45,7 @@ public class LoginResponseEntity extends ResponseEntity {
return new BilibiliAccount( return new BilibiliAccount(
this.data.accessToken, this.data.accessToken,
this.data.refreshToken, this.data.refreshToken,
this.data.mid, this.data.userId,
this.data.expiresIn, this.data.expiresIn,
this.timestamp this.timestamp
); );
@ -64,7 +64,7 @@ public class LoginResponseEntity extends ResponseEntity {
@SerializedName("refresh_token") @SerializedName("refresh_token")
private String refreshToken; private String refreshToken;
@SerializedName("mid") @SerializedName("mid")
private long mid; private long userId;
@SerializedName("expires_in") @SerializedName("expires_in")
private long expiresIn; private long expiresIn;
@ -84,12 +84,12 @@ public class LoginResponseEntity extends ResponseEntity {
this.refreshToken = refreshToken; this.refreshToken = refreshToken;
} }
public long getMid() { public long getUserId() {
return mid; return userId;
} }
public void setMid(long mid) { public void setUserId(long userId) {
this.mid = mid; this.userId = userId;
} }
public long getExpiresIn() { public long getExpiresIn() {

View File

@ -45,7 +45,7 @@ public class RefreshTokenResponseEntity extends ResponseEntity {
return new BilibiliAccount( return new BilibiliAccount(
this.data.accessToken, this.data.accessToken,
this.data.refreshToken, this.data.refreshToken,
this.data.mid, this.data.userId,
this.data.expiresIn, this.data.expiresIn,
this.ts this.ts
); );
@ -60,7 +60,7 @@ public class RefreshTokenResponseEntity extends ResponseEntity {
*/ */
@SerializedName("mid") @SerializedName("mid")
private long mid; private long userId;
@SerializedName("refresh_token") @SerializedName("refresh_token")
private String refreshToken; private String refreshToken;
@SerializedName("access_token") @SerializedName("access_token")
@ -68,12 +68,12 @@ public class RefreshTokenResponseEntity extends ResponseEntity {
@SerializedName("expires_in") @SerializedName("expires_in")
private long expiresIn; private long expiresIn;
public long getMid() { public long getUserId() {
return mid; return userId;
} }
public void setMid(long mid) { public void setUserId(long userId) {
this.mid = mid; this.userId = userId;
} }
public String getRefreshToken() { public String getRefreshToken() {

View File

@ -8,7 +8,7 @@ public class Config {
private String username; private String username;
private String password; private String password;
private int roomId; private long roomId;
static Config getInstance() { static Config getInstance() {
return config; return config;
@ -34,11 +34,11 @@ public class Config {
this.password = password; this.password = password;
} }
int getRoomId() { long getRoomId() {
return roomId; return roomId;
} }
public void setRoomId(int roomId) { public void setRoomId(long roomId) {
this.roomId = roomId; this.roomId = roomId;
} }

View File

@ -130,7 +130,7 @@ public class LiveClientTest {
LOGGER.info("[SendGift] {} give {}*{}", LOGGER.info("[SendGift] {} give {}*{}",
data.getUsername(), data.getUsername(),
data.getGiftName(), data.getGiftName(),
data.getNum() data.getNumber()
); );
} }