Overview
Connection Information
The websocket server listens at
wss://praetorpoker.com/gameserver
HMAC Authentication
The game server uses HMACs (hash-based message authentication code) to authenticate messages sent by players.
A brief explanation: HMACs are created by concatenating a
key string and a
message string and then running the concatenated string through a hash function.
The game server uses the SHA-256 hash function.
For all messages sent by a bot to the server, The HMAC
key string will be the <secret string> chosen by the user during the initial registration process.
The HMAC
message string depends on what kind of message the bot is sending to the game server:
message_type | HMAC message component |
check_in | <match_id> (as a string) |
input_action | <action> |
For more information on HMAC see the
HMAC Wikipedia page.
The Python starter bot has a simple HMAC implementation method that can be copied.
Card Messages
Messages that contain card values (hole cards, flop, turn, river) are designated as "card string" type and use the following scheme:
Each card is represented by a 2-character string. The first character is the card's rank and the secnond character is the card's suit.
The rank character is either a number or a capital letter. The suit character is a lowercase letter. If multiple cards are included in a single card string, the cards are separated by an underscore character.
Rank | Single character representation |
Ace | A |
Two | 2 |
Three | 3 |
Four | 4 |
Five | 5 |
Six | 6 |
Seven | 7 |
Eight | 8 |
Nine | 9 |
Ten | T |
Jack | J |
King | Q |
Queen | K |
Suit | Single character representation |
Hearts | h |
Clubs | c |
Diamonds | d |
Spades | s |
Card string examples:
The Ace of Hearts is represented as "Ah"
Hole cards containing the Three of Spades and the Ten of Clubs is represented as "3s_Tc"
Messages sent from player to game server
Check-in
This is the first message sent by a bot once it connects to the websocket server.
Field | Type | Description |
---|
message_type | string (constant) | Always equals "check_in" for check-in messages |
player_id | int | |
match_id | int | |
signature | string | HMAC signature created according to the HMAC signature protocol |
This message is sent each time a bot intends to make an action. In case of an invalid input action, the game engine will attempt to reassign the action according to the
game rules.
If the action cannot be reassigned it will be designated as a fold, so it is recommended to implement some action validation in the bot.
Field | Type | Description |
---|
message_type | string (constant) | Always equals "input_action" for input_action messages |
player_id | int | |
match_id | int | |
action | string | Action that the player is taking. See Action table for details |
signature | string | HMAC signature created according to the HMAC signature protocol |
Messages sent from game server to player
Check-in confirmation
Sent privately to a participant to indicate successful check-in.
Field | Type | Description |
---|
message_type | string (constant) | Always equals "checkin_confirmation" for checkin confirmation messages |
player_id | int | |
match_id | int | |
Check-in Error
Sent privately to a participant to indicate an unsuccessful check-in attempt. Most commonly occurs if the match_id is incorrect in the bot's initial checkin message or if the bot continues to send check-in messages after it has already successfully checked in.
Field | Type | Description |
---|
message_type | string (constant) | Always equals "checkin_error" for checkin error messages |
player_id | int | |
match_id | int | |
error_type | string | Cause of the unsuccessful checkin attempt |
Initial match state
Broadcast to all participants at the beginning of a match after everyone has checked in.
Field | Type | Description |
---|
message_type | string (constant) | Always equals "initial_game_state" for initial game state messages |
starting_stack | int | Amount of chips each player starts the match with |
blind_amounts | | |
---- small | int | Small blind size |
---- big | int | Big blind size |
player_names | | |
---- player_1 | string | Player 1 public username |
---- player_2 | string | Player 2 public username |
New hand
Sent privately to each participant at the beginning of each hand. The message is identical across participants except for the hole_cards field.
Field | Type | Description |
---|
message_type | string (constant) | Always equals "new_hand" for new hand mesages |
blinds | | |
---- big | string | Player posting big blind |
---- small | string | Player posting small blind |
current_stage | string (constant) | Current hand stage. Value is always "preflop" in the new_hand message |
hole_cards | string | String representation of hole cards |
Next to act
Sent privately to the participant who is next to act.
Field | Type | Description |
---|
message_type | string (constant) | Always equals "next_to_act" for next-to-act messages |
player_id | int | |
match_id | int | |
to_call | int | Amount required to call existing bet |
current_round_bet | int | Size of player's existing bet for the current round |
available_actions | string array | List of valid actions for this turn |
Effective action
Broadcast to all participants after a player makes an action.
Field | Type | Description |
---|
message_type | string (constant) | Always equals "effective_action" for effective action messages |
player_id | int | |
match_id | int | |
action | string | The action taken by the player. This will be the same as the input action except in cases of an invalid input action |
pot_size | int | Pot size after accounting for this action |
New stage
Broadcast to all participants when a hand advances to a new stage.
Field | Type | Description |
---|
message_type | string (constant) | Always equals "stage" for new stage messages |
current_stage | string | Current hand stage. Possible values are {"preflop", "flop", "turn", "river"} |
board_update | card string | New cards added to the board |
End hand
Broadcast to all players at the end of a hand. Note that some of the contents of this message may change depending on the hand outcome.
Field | Type | Description |
---|
message_type | string (constant) | Always equals "end_hand" for end hand messages |
winner | string | Public username of player who won the hand. In case of a split pot, the Type will instead be an array of strings containing the public usernames of all winners. |
stack_size | | |
---- <player_1 username> | int | Player 1's stack size at the end of the hand |
---- <player_2 username> | int | Player 2's stack size at the end of the hand |
hole_cards | | This is an optional field. hole_cards will be included if and only if the hand reached showdown |
---- <player_1 username> | string | Player 1's hole cards |
---- <player_2 username> | string | Player 2's hole cards |
End match
Broadcast to all players at the end of a match.
Field | Type | Description |
---|
message_type | string (constant) | Always equals "end_match" for end match messages |
winner | string | username of player who won the match |