Soulless.Packet.GamePacket (Soulless v0.3.0)

Copy Markdown View Source

Summary

Types

cache()

@type cache() :: %{required(non_neg_integer()) => module() | rpc()}

kind()

@type kind() :: :notice | :request | :response

kind_or_unknown()

@type kind_or_unknown() :: kind() | :unknown

rpc()

@type rpc() :: [
  request_module: lq_module :: module(),
  response_module: lq_module :: module(),
  rpc: rpc_name()
]

rpc_name()

@type rpc_name() :: String.t()

t()

@type t() :: %Soulless.Packet.GamePacket{
  body: struct(),
  kind: kind(),
  request_id: non_neg_integer() | nil,
  rpc: rpc_name() | nil
}

Functions

decode_wrapper(body)

@spec decode_wrapper(body :: binary()) :: {:ok, struct()} | {:error, any()}

get_rpc_by_identifier(rpc_name)

@spec get_rpc_by_identifier(rpc_name()) ::
  {:ok, rpc()} | {:error, error :: String.t()}

get_type_by_identifier(rpc_name)

@spec get_type_by_identifier(rpc_name()) ::
  {:ok, lq_module :: module()} | {:error, String.t()}

parse(binary, module_cache)

@spec parse(binary(), cache()) :: {:ok, {t(), cache()}} | {:error, String.t()}

parse_raw_packet(binary)

@spec parse_raw_packet(binary()) :: {:ok, map()} | {:error, String.t()}

serialize(message, module_cache)

@spec serialize(t(), cache()) :: {nonempty_binary(), cache()}

wrap_and_encode(rpc_name, body)

@spec wrap_and_encode(rpc_name(), body :: binary()) :: binary()