mirror of
https://github.com/czp3009/bilibili-api.git
synced 2024-12-21 20:30:28 +08:00
增加弹幕推送流中的数据包类型 CHANGE_ROOM_INFO
This commit is contained in:
parent
dc7c763433
commit
79af856db9
@ -319,6 +319,7 @@ API 文档
|
|||||||
| 事件 | 抛出条件 |
|
| 事件 | 抛出条件 |
|
||||||
| :--- | :--- |
|
| :--- | :--- |
|
||||||
| ActivityEventPackageEvent | 收到 ACTIVITY_EVENT 数据包 |
|
| ActivityEventPackageEvent | 收到 ACTIVITY_EVENT 数据包 |
|
||||||
|
| ChangeRoomInfoPackageEvent | 收到 CHANGE_ROOM_INFO 数据包 |
|
||||||
| ConnectionCloseEvent | 连接断开(主动或被动) |
|
| ConnectionCloseEvent | 连接断开(主动或被动) |
|
||||||
| ConnectSucceedEvent | 进房成功 |
|
| ConnectSucceedEvent | 进房成功 |
|
||||||
| CutOffPackageEvent | 收到 CUT_OFF 数据包 |
|
| CutOffPackageEvent | 收到 CUT_OFF 数据包 |
|
||||||
|
4
record/bullet_screen_stream_json/CHANGE_ROOM_INFO.json
Normal file
4
record/bullet_screen_stream_json/CHANGE_ROOM_INFO.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"cmd": "CHANGE_ROOM_INFO",
|
||||||
|
"background": "http://static.hdslb.com/live-static/images/bg/4.jpg"
|
||||||
|
}
|
@ -1,26 +0,0 @@
|
|||||||
package com.hiczp.bilibili.api.interceptor;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import okhttp3.Interceptor;
|
|
||||||
import okhttp3.Response;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class PrintResponseBodyInterceptor implements Interceptor {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(PrintResponseBodyInterceptor.class);
|
|
||||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Response intercept(Chain chain) throws IOException {
|
|
||||||
Response response = chain.proceed(chain.request());
|
|
||||||
|
|
||||||
JsonObject jsonObject = InterceptorHelper.getJsonInBody(response);
|
|
||||||
LOGGER.info(GSON.toJson(jsonObject));
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.hiczp.bilibili.api.live.socket.entity;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
public class ChangeRoomInfoEntity implements DataEntity {
|
||||||
|
/**
|
||||||
|
* cmd : CHANGE_ROOM_INFO
|
||||||
|
* background : http://static.hdslb.com/live-static/images/bg/4.jpg
|
||||||
|
*/
|
||||||
|
|
||||||
|
@SerializedName("cmd")
|
||||||
|
private String cmd;
|
||||||
|
@SerializedName("background")
|
||||||
|
private String background;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCmd() {
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCmd(String cmd) {
|
||||||
|
this.cmd = cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBackground() {
|
||||||
|
return background;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackground(String background) {
|
||||||
|
this.background = background;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.hiczp.bilibili.api.live.socket.event;
|
||||||
|
|
||||||
|
import com.hiczp.bilibili.api.live.socket.entity.ChangeRoomInfoEntity;
|
||||||
|
|
||||||
|
public class ChangeRoomInfoPackageEvent extends ReceiveDataPackageEvent<ChangeRoomInfoEntity> {
|
||||||
|
public ChangeRoomInfoPackageEvent(Object source, ChangeRoomInfoEntity entity) {
|
||||||
|
super(source, entity);
|
||||||
|
}
|
||||||
|
}
|
@ -197,6 +197,11 @@ public class LiveClientHandler extends SimpleChannelInboundHandler<Package> {
|
|||||||
eventCreationExpression = () -> new RoomShieldPackageEvent(this, GSON.fromJson(jsonObject, RoomShieldEntity.class));
|
eventCreationExpression = () -> new RoomShieldPackageEvent(this, GSON.fromJson(jsonObject, RoomShieldEntity.class));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
//更换房间背景图片
|
||||||
|
case "CHANGE_ROOM_INFO": {
|
||||||
|
eventCreationExpression = () -> new ChangeRoomInfoPackageEvent(this, GSON.fromJson(jsonObject, ChangeRoomInfoEntity.class));
|
||||||
|
}
|
||||||
|
break;
|
||||||
//被 B站 管理员强制中断
|
//被 B站 管理员强制中断
|
||||||
case "CUT_OFF": {
|
case "CUT_OFF": {
|
||||||
eventCreationExpression = () -> new CutOffPackageEvent(this, GSON.fromJson(jsonObject, CutOffEntity.class));
|
eventCreationExpression = () -> new CutOffPackageEvent(this, GSON.fromJson(jsonObject, CutOffEntity.class));
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.hiczp.bilibili.api.test;
|
package com.hiczp.bilibili.api.test;
|
||||||
|
|
||||||
import com.hiczp.bilibili.api.BilibiliAPI;
|
import com.hiczp.bilibili.api.BilibiliAPI;
|
||||||
import com.hiczp.bilibili.api.interceptor.PrintResponseBodyInterceptor;
|
|
||||||
import okhttp3.logging.HttpLoggingInterceptor;
|
import okhttp3.logging.HttpLoggingInterceptor;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ public class GetAwardsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getAwards() throws Exception {
|
public void getAwards() throws Exception {
|
||||||
BILIBILI_API
|
BILIBILI_API
|
||||||
.getLiveService(Collections.singletonList(new PrintResponseBodyInterceptor()), HttpLoggingInterceptor.Level.BODY)
|
.getLiveService(Collections.emptyList(), HttpLoggingInterceptor.Level.BODY)
|
||||||
.getAwards()
|
.getAwards()
|
||||||
.execute()
|
.execute()
|
||||||
.body();
|
.body();
|
||||||
|
Loading…
Reference in New Issue
Block a user