1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

雀魂 API リクエスト

Last updated at Posted at 2022-09-13

すべて自己責任の上で実行してください。

雀魂の API リクエストの内容を確認する方法と、API を呼び出す方法をまとめました。

mitmproxy

mitmproxy というフリーソフトを使って、API リクエストの内容を確認できます。別途、デコードのために protoc と呼ばれるツールが必要です。

API Visualizer

雀魂の API リクエスト内容を可視化する API Visualizer です。Docker のインストールが必要となります。

牌譜屋

Node.js を使って、ゲームクライアントを起動せずに API を呼び出すことができます。牌譜屋で使用されているコードです。ちなみに、TypeScript / Python / Go / Elixir で書かれた同じ趣旨のコードがあります。

開発者ツール

リクエスト内容の確認

API リクエストの内容をコンソールに出力するコードです。

protobuf.rpc.Service.prototype._rpcCall ??= protobuf.rpc.Service.prototype.rpcCall;
protobuf.rpc.Service.prototype.rpcCall = function(api, _, __, req, callback) {
    const _callback = callback;
    callback = (err, res) => {
        console.log(
            "API:", api.name,
            "\nReq:", req,
            "\nRes:", res,
        );
        _callback(err, res);
    };
    this._rpcCall(...arguments);
};

NOTIFY メッセージをコンソールに出力するコードです。

net.Socket.prototype.__handleMsg ??= net.Socket.prototype._handleMsg;
net.Socket.prototype._handleMsg = function(msg) {
    if (msg[0] === net.HeaderType.NOTIFY) {
        console.log(net.MessageWrapper.decodeMessage(msg.slice(1)));
    }
    this.__handleMsg(...arguments);
};

API の呼び出し

次のコードは、fetchReviveCoinInfo という API を呼び出します。復活コインを受け取ったかどうかの確認が可能です。

var Lobby = app.NetAgent._net_lobby._socket.services_.Lobby;
var req = {};
Lobby.fetchReviveCoinInfo(req, (err, res) => {
    console.log("has_gained:", res.has_gained);
});

API の仕様については、こちらのページを参照して下さい。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?