The TetriNET protocol specifies the following message types for communication sent from the client to the server it is connected to:

(Note: "local player" is a convention referring to the user of the client sending the message.)

h1. Connecting

h2. Login:

see [[logging in to a server]]

h2. Team Name:

<code>team <number> <team name></code>

Sent to the server immediately after the local player's player number is received. Identifies the name of the team the local player plays for.

|_. arguments |_. type |_. values |_. meaning |
| <code>number</code> | integer | <code>1</code> - <code>6</code> | the local player's player number |
| <code>team name</code> | string | | the name of the local player's team |

h2. Client Info:

<code>clientinfo <client name> <client version></code>

(Optional; not part of the protocol)

Used to send the name and version of the client application to the server. Not all servers will accept this message—those that do will request it by sending a Client Info Request (see [[tetrinet protocol: server-to-client messages]].)

|_. arguments |_. type |_. values |_. meaning |
| <code>client name</code> | string | | the name of the client application (e.g., "iTetrinet") |
| <code>client version</code> | string | | the client application's version number, as a string (e.g., "1.0.0") |

h1. Player Communication

h2. Partyline Chat Message:

<code>pline <sendernum> <message></code>

Used to send partyline chat messages from the local player to the other players on the server. This message is usually echoed to all other connected clients, but many servers support the use of slash commands, (such as <code>/list</code> or <code>/whisper</code>) which are handled by the server and not echoed. Note that <code>/me</code> is <i>not</i> a server-side slash command; see "Partyline Chat Action," below.

|_. arguments |_. type |_{width:45px}. values |_. meaning |
| <code>sendernum</code> | integer | <code>1</code> - <code>6</code> | the local player's player number |
| <code>message</code> | string | | the contents of the message to send. may contain [[formatting characters|partyline formatting characters]] |

h2. Partyline Chat Action:

<code>plineact <sendernum> <action></code>

Used to send partyline actions (messages beginning with <code>/me</code>, also known as emotes) from the local player to the other players on the server. These messages should <i>not</i> contain the <code>/me</code> token.

|_. arguments |_. type |_{width:45px}. values |_. meaning |
| <code>sendernum</code> | integer | <code>1</code> - <code>6</code> | the local player's player number |
| <code>message</code> | string | | the message contents following the <code>/me</code> token |

h2. Game Chat Message:

<code>gmsg <message></code>

Used to send a game message (i.e., a message entered in the chat field underneath the gameplay areas) from the local player to the other players on the server. Note that this message does not contain the local player's player number, and, as a result, the receiving client does not know from whom it came. It is recommended that clients append the local player's nickname to the front of the message contents before sending it.

|_. arguments |_. type |_{width:45px}. values |_. meaning |
| <code>message</code> | string | | the contents of the chat message, perhaps with the local player's nickname appended in front |

h1. Gameplay

h2. Start/Stop Game:

<code>startgame <state> <playernum></code>

Used to start a new game, or stop a game in progress. Servers will only respond to this message if it is sent by the channel operator, i.e., the connected player with the smallest player number.

|_. arguments |_. type |_{width:45px}. values |_. meaning |
| <code>state</code> | boolean | <code>1</code> or <code> 0</code> | indicates whether the game should be started or stopped: <code>1</code> signifies "start game," <code>0</code> signifies "stop game" |
| <code>playernum</code> | integer | <code>1</code> - <code>6</code> | the local player's player number; must be the smallest player number among players in the server for this message to work |

h2. Field Update:

See [[field updates]]

h2. Level Update:

<code>lvl <playernum> <levelnum></code>

Sent when the local player reaches a higher level in the game, which occurs when the local player completes a certain number of lines, specified in the [[new game rules string]] at the beginning of the game.

|_. arguments |_. type |_{width:45px}. values |_. meaning |
| <code>playernum</code>| integer | <code>1</code> - <code>6</code> | the local player's player number |
| <code>levelnum</code> | integer | | the local player's new game level |

h2. Send Special:

<code>sb <targetnum> <specialtype> <sendernum></code>

Sent when the local player uses a [[special|special blocks]] on another player.

|_. arguments |_. type |_. values |_. meaning |
| <code>targetnum</code> | integer | <code>1</code> - <code>6</code> | the player chosen by the local player to receive the special |
| <code>specialtype</code> | char | <code>a</code>, <code>b</code>, <code>c</code>, <code>g</code>, <code>n</code>, <code>o</code>, <code>q</code>, <code>r</code>, or <code>s</code> | the type of special used (see [[special blocks]]) |
| <code>sendernum</code> | integer | <code>1</code> - <code>6</code> | the local player's player number |

h2. Send Classic-Style Add-Lines:

<code>sb 0 cs<numlines> <sendernum></code>

(A minor variation of the "Send Special" message, above.)

Sent when the local player completes multiple lines simultaneously in a game with "classic mode" enabled, (see [[new game rules string]]) triggering a [[classic-style add|classic-style adds]]. The <code>targetnum</code> field of the message should always be <code>0</code>, since classic-style adds affect all players except the sender.

|_. arguments |_. type |_{width:70px}. values |_. meaning |
| <code>numlines</code> | char | <code>1</code>, <code>2</code>, or <code>4</code> | the number of lines added to other players' fields; see [[classic-style adds]] |
| <code>sendernum</code> | integer | <code>1</code> - <code>6</code> | the local player's player number |

h2. Player Lost:

<code>playerlost <playernum></code>

Sent when the local player loses the game; i.e., when his or her field is full to the point that the next block cannot be moved onto it.

_Implementation note:_ some servers (Jetrix for instance) expect the client to send a randomly-filled "death field" (via a [[field update|field updates]] message) after the player loses, but before sending the "player lost" message.

|_. arguments |_. type |_{width:45px}. values |_. meaning |
| <code>playernum</code> | integer | <code>1</code> - <code>6</code> | the local player's player number |

h2. Pause/Resume Game:

<code>pause <state> <playernum></code>

Used to pause or resume a game in progress. Like the Start/Stop Game message, servers will only respond to this message if it is sent by the channel operator.

|_. arguments |_. type |_{width:45px}. values |_. meaning |
| <code>state</code> | boolean | <code>1</code> or <code>0</code> | indicates whether the game should be paused or resumed: <code>1</code> signifies "pause," <code>0</code> signifies "resume" |
| <code>playernum</code> | integer | <code>1</code> - <code>6</code> | the local player's player number; must be the smallest player number among players in the server for this message to work |