Closed ZJChe closed 1 year ago
I'm sending messages that the Flash client sent a while ago, so they are based on real client-server communication. It looks like tenhou has now adjusted the protocol a bit, but old messages are still working fine.
To watch the game you can try this code: https://github.com/MahjongRepository/phoenix-logs/blob/18351052c10080564ef4e848e1709ce17067d9a5/live_games/watcher.py#L12
It connects to the ongoing game and stores all messages in array.
Thanks! That code inspired me a lot. I'm amazed at so many codes about Riichi Mahjong that you wrote😄
I still have some questions:
I need to watch an uncertain number of games at the same time, possibly up to 10.
@Nihisil
Is it supposed to be here😥 I don't see anything related to IP or PORT here. I can see in the "message" section that messages are receiving and sending.
In FF it shows IP address, and default SSL port. Probably you can try just use host b-wc.mjv.jp
and 443 port for to connection (I didn't try that):
I got IPs and ports for my code from Wireshark when sniffed traffic from old Flash version.
Hi developer @Nihisil , I'm very interested in your AI developed. I'm mostly interested in the socket communication part that allows the AI to play game automatically through sending text messages. So I'm now currently learning your code and developing a program to watch a tenhou game and print out the results. But I meet some problems.
By clicking into a tenhou game link obtained from tenhou.net/0/wg in my browser, and press F12, I saw the message sent in order to start watching a game:
So after I connected by socket and got authenticated (this part is same as your code), I sent
<WG id="8DAC0C1A" tw=0 />
, but I got no reply at all. At this stage if a sent a message requesting for a game (copied from your code), I could get reply and start a game. So I'm doubting whether I sent the correct message.Later on I compared other messages my browser sent with your code's, and I found some differences: The Login message:
Your code has an extra
tid="f0"
The alive message when hanging around in lobby:
The numbers within the messages are different.
Since both messages work for sure, I wonder how you found out the correct message to send, and why you did not choose the same message as the browser version. (Note, most other messages sent are the same)
I'm a beginner to socket, and I'm purely coding for fun and learning. I would appreciate it very much if you could give me some hints and guidance!