WardrikSlack.Socket (wardrik_slack v0.1.0-rc.1)

Copy Markdown

Connects to Slack over Socket Mode with the channel's :app_token. Needs no public address.

For testing. Slack expects apps in use to take events over HTTP. See WardrikSlack.HTTP.

  • Each envelope is handed to WardrikSlack.Dispatch in a task.
  • Messages are acknowledged after they're handled, so Slack resends one lost to a crash. Other envelopes are acknowledged at once.
  • When the connection closes, as Slack does every few hours, it reconnects. Backoff doubles from one second after each failure, up to a minute.

Summary

Functions

Returns a specification to start this module under a supervisor.

Parses a text frame from Slack.

Starts the connection for channel.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

envelope(text)

@spec envelope(String.t()) ::
  :hello
  | :disconnect
  | {:ack, String.t(), {:interactive, map()} | {:event, map()} | :ignore}
  | {:ack_after, String.t(), {:message, map()}}
  | :ignore

Parses a text frame from Slack.

Returns :hello, :disconnect, {:ack, id, work} to acknowledge now, {:ack_after, id, {:message, callback}} to acknowledge once handled, or :ignore.

start_link(channel)

@spec start_link(WardrikChannel.Channel.t()) :: GenServer.on_start()

Starts the connection for channel.