Skip to main content
“Chat” is actually two independent subsystems. Real-time message text never touches the main game socket at all; it rides a second, JSON-over-WebSocket connection with its own auth, its own server discovery, and its own message-signing scheme.

Two chat channels

Sending an alliance/world chat message: cmd="chat.room" on the WebSocket, not the SFS-side al.msg/chat.country commands (those are for sharing a rich attachment/card into a room, no free-text field). Every message is signed:
In 1.0.364 the Lua builds the alliance room id deterministically, alliance_<sourceServerId>_<allianceId>, with alliance_manager_<sid>_<aid> for the R4/R5 room and alliance_<sid>_<aid>_Notice for the notice room, and it treats any other id as a mismatch to re-sync (ChatRoomManager; static-analysis-only). How the client gets into that room depends on a server switch:
  • By default, the client joins the room itself with room.joinMulti {rooms: [{id, group: "alliance"}]} on the WebSocket.
  • With the DataConfig switch room_join_control on, the server grants membership instead. The client sends chat.permission.syn {action} on the SFS socket (joinAlliance, leaveAlliance, rankChange, or notCheck), and the chat server answers on the WebSocket with push.room.synPermission {roomId, auth, group}.
common.chat.room.id on the SFS socket returns allRooms[{group, roomId}], but the client sends it only when the C# switch ClientSwitch.CHAT_SERVER_ROOMLIST is on. Earlier versions of this page said the alliance room id isn’t derivable from the alliance id and must be fetched with common.chat.room.id. If that came from a live observation, it was probably made in room_join_control mode; which mode production runs in hasn’t been checked.

Chat WebSocket transport

Everything in this section is from the 1.0.364 Lua (ChatNetManager, ChatManager2) and C# (ChatService), re-checked against 1.0.370 (ChatService.RequestServerList, Assembly-CSharp.decompiled.cs:70626-70660; WebSocketItem, 70348-70403), and is static-analysis-only. Chat starts once per login, after the init push has been processed.
  1. Discovery. An HTTPS form POST to the first reachable of three line-specific URLs, starting with the game socket’s current line:
    When the DataConfig switch CheckChatNewLine is on, the client posts to /gameservice/chat_server_links.php on the three lastwar-serverlist-* hosts instead. The form fields are t (server time in seconds), s (an MD5 signature), a (the app id), u (the uid), serverId, and f=cn in China only. The response is {code, data: [{protocol, ip, port}], data_new}; the server switch ChatUseNewLine selects data_new. On failure the client retries every 3 s, rotating URLs.
  2. Connect. The WebSocket URL is {protocol}://{ip}:{port}, with no path. The handshake carries five headers: APPID, TIME (server time in ms), UID, SIGN, and CHATTOKEN (the chatToken from init). SIGN is the connectionSign that every frame signature above includes.
  3. Keepalive. The client pings every 3 s and closes the connection after 9 s without any frame. The server also sends literal heartbeat text frames.
  4. Session. The server pushes login.success. The client then sends user.setInfo, user.setSwitchFlag, room.getCustomRoomListV2, and room.joinMulti, and once those answer, pulls each joined room’s newest page with history.roomsv2.
  5. One session per uid. another.login means the same uid connected to chat elsewhere; the client closes and doesn’t reconnect.
  6. Frames. Every outbound command is signed, not just chat.room, using the formula above. Replies reuse the request’s cmd with a result object; pushes carry data.
Nothing claimable travels on the chat socket. Red packets, gift boxes, and shared rewards are claimed with game-socket commands; the chat socket only delivers the ids those commands need.

goclient’s read-only chat reader

Since 1.0.370 goclient has a read-only reader (internal/chat, static-analysis-only). It runs the discovery and connect steps above, then waits for login.success and sends only two commands: room.joinMulti for the alliance room (or, with room_join_control on, waits for push.room.synPermission) and history.roomsv2 for that room’s newest page. It listens 3 s for room pushes and closes. It never sends user.setInfo, user.setSwitchFlag, a message, a like or a share, and refuses to write any other command. It keeps only posts 600 (treasure dug up), 611 (red packet), 693 and 695 (firework chests). Its consumers are chat-scan (log only), red-packets (post 611, open.red.packet on the game socket), fireworks-chat (posts 693, 695) and alliance-treasures-chat (post 600); one chat read per run serves all four, and none is opened unless one of them runs. Because the chat server keeps one session per uid, that read sends the phone’s chat session another.login, and the phone’s chat doesn’t reconnect by itself, the way the run’s game login drops the phone’s game session.

Core Alliance commands

Core Mail commands

What mail.reward.batch’s type holds

The 1.0.364 Lua (MailRewardBatchMessage) sends type as a UtfString holding an internal mail group id, never the mail’s own raw type (static-analysis-only): The client maps each raw mail type to a group through MailTypeToInternalGroup: 140 rows in MailEnum.lua 1.0.367, with every row of table mail_group applied over them at startup (MailDataManager.lua:30-36), 144 types in all with table 39879. Its Claim All walks the groups in the order 2, 3, 4, 9, 5, 6, 7, 8 (MailShowGroup), one call per group. Mail whose raw type has no group is in no list the client keeps, so it is never read or claimed. Mail in the hide group 1 (arena, truck and other battle reports no tab lists) is never claimed in bulk, but ReadAllHideMail marks it read at every login. An optional types UtfString exists too, but the claim-all path never uses it. The 3, 4, and 9 in the original live capture of the real client are exactly the alliance, activity, and season group ids. goclient now sends the client’s shape: one call per group in that order, type as the group id UtfString. The map is generated from MailEnum.lua and table mail_group (genmailgroups, mail_groups_gen.go). Hide-group mail is marked read and not claimed, mail in no group is left alone, and the run logs the types whose rewards it left. That shape is static-analysis-only until a live run confirms it. An earlier goclient sent type as an Int holding the raw mail type, and the server accepted that too: confirmed live, mail.reward.batch returned {success=true}, and each unclaimed mail disappeared from the inbox after one run.

Government (“Kingdom”) system

A cross-alliance elected-leadership layer on top of the world map: choose.king, kingdom.position.appoint/.apply/.resign, cross.throne.* (20 requests and two pushes in 1.0.370, for a cross-server king-of-the-hill tournament). Ordinary SFS commands, no separate channel.