# `Phoenix.Socket.Message`
[🔗](https://github.com/phoenixframework/phoenix/blob/v1.8.12/lib/phoenix/socket/message.ex#L1)

Defines a message dispatched over transport to channels and vice-versa.

The message format requires the following keys:

  * `:topic` - The string topic or topic:subtopic pair namespace, for
    example "messages", "messages:123"
  * `:event`- The string event name, for example "phx_join"
  * `:payload` - The message payload
  * `:ref` - The unique string ref
  * `:join_ref` - The unique string ref when joining

# `t`

```elixir
@type t() :: %Phoenix.Socket.Message{
  event: term(),
  join_ref: term(),
  payload: term(),
  ref: term(),
  topic: term()
}
```

# `from_map!`

Converts a map with string keys into a message struct.

Raises `Phoenix.Socket.InvalidMessageError` if not valid.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
