Skip to content

Commit

Permalink
v0.2.1 (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
scx567888 authored Mar 6, 2024
1 parent b8c3afc commit 71852f9
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</parent>

<artifactId>live-room-watcher</artifactId>
<version>0.2.0</version>
<version>0.2.1</version>

<name>Live Room Watcher</name>
<url>https://github.com/scx567888/live-room-watcher</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ public class _560GameApi {

public static final String VALIDATE_USER_URL = "/barrgame/grant_api/validateUser";
public static final String GET_GIFT_LIST_URL = "/barrgame/grant_api/getGiftList";
public static final String CLOSE_GAME_NOTIFY_URL = "/barrgame/grant_api/closeGameNotify";
public static final String REPORT_GAME_NOTIFY_URL = "/barrgame/grant_api/reportGameNotify";

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import static cool.scx.live_room_watcher.impl._560game._560GameApi.GET_GIFT_LIST_URL;
import static cool.scx.live_room_watcher.impl._560game._560GameApi.VALIDATE_USER_URL;
import static cool.scx.live_room_watcher.impl._560game._560GameApi.*;
import static cool.scx.live_room_watcher.impl._560game._560GameHelper.getSign;
import static cool.scx.util.RandomUtils.randomString;

Expand Down Expand Up @@ -107,6 +106,78 @@ public String validateUser0(String username, String password) throws IOException
return jsonNode.get("data").get("ws_url").asText();
}

public JsonNode closeGameNotify(String username){
try {
return closeGameNotify0(username);
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
}

/**
* 关闭游戏推送通知
*
* @param username username
* @return a
* @throws IOException a
* @throws InterruptedException a
*/
public JsonNode closeGameNotify0(String username) throws IOException, InterruptedException {
var map = new HashMap<String, String>();
map.put("mch_id", this.mch_id);
map.put("username", username);
map.put("game_id", this.game_id);
map.put("nonce", randomString(32));

var sign = getSign(map, secret);
map.put("sign", sign);

var post = ScxHttpClientHelper.post(root_uri + CLOSE_GAME_NOTIFY_URL,
new JsonBody(
map
));
var body = post.body();
var bodyStr = body.toString();
var jsonNode = ObjectUtils.jsonMapper().readTree(bodyStr);
String message = jsonNode.get("message").asText();
if (!"success".equals(message)) {
throw new RuntimeException("返回数据有误");
}
return jsonNode;
}

public JsonNode reportGameNotify(String username) {
try {
return reportGameNotify0(username);
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
}

public JsonNode reportGameNotify0(String username) throws IOException, InterruptedException {
var map = new HashMap<String, String>();
map.put("mch_id", this.mch_id);
map.put("username", username);
map.put("game_id", this.game_id);
map.put("nonce", randomString(32));

var sign = getSign(map, secret);
map.put("sign", sign);

var post = ScxHttpClientHelper.post(root_uri + REPORT_GAME_NOTIFY_URL,
new JsonBody(
map
));
var body = post.body();
var bodyStr = body.toString();
var jsonNode = ObjectUtils.jsonMapper().readTree(bodyStr);
String message = jsonNode.get("message").asText();
if (!"success".equals(message)) {
throw new RuntimeException("返回数据有误");
}
return jsonNode;
}

public List<_560GiftListEntry> getGiftList() throws IOException, InterruptedException {
var map = new HashMap<String, String>();
map.put("mch_id", this.mch_id);
Expand Down

0 comments on commit 71852f9

Please sign in to comment.