Server message

From pikdum/thistle_tea · View interactive version

Server message is an AI agent skill from the GitHub repository pikdum/thistle_tea. Implement Thistle Tea SMSG_* server messages following our architecture patterns. Use this when asked to implement a new message or you need to use one that isn't implemented yet.

How to use this skill

Skill file

Create/modify a module under lib/game/network/message/ that:

Quick examples

Minimal payload (SMSG_PONG):

defmodule ThistleTea.Game.Network.Message.SmsgPong do
  @moduledoc false
  use ThistleTea.Game.Network.ServerMessage, :SMSG_PONG

  defstruct [:sequence_id]

  @impl ServerMessage
  def to_binary(%__MODULE__{sequence_id: sequence_id}) do
    <<sequence_id::little-size(32)>>
  end
end

Conditional payload (SMSG_AUTH_RESPONSE):

defmodule ThistleTea.Game.Network.Message.SmsgAuthResponse do
  @moduledoc false
  use ThistleTea.Game.Network.ServerMessage, :SMSG_AUTH_RESPONSE

  @result_auth_ok 0x0C
  @result_auth_wait_queue 0x1B

  defstruct [:result, :billing_time, :billing_flags, :billing_rested, :queue_position]

  @impl ServerMessage
  def to_binary(%__MODULE__{} = msg) do
    <<msg.result::little-size(8)>> <>
      case msg.result do
        @result_auth_ok ->
          <<msg.billing_time::little-size(32), msg.billing_flags::little-size(8),
            msg.billing_rested::little-size(32)>>

        @result_auth_wait_queue ->
          <<msg.queue_position::little-size(32)>>

        _ ->
          <<>>
      end
  end
end

How to find the packet spec

Workflow

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.