class

Amber::WebSockets::Channel

Inherits Reference < Object

Sockets subscribe to Channels, where the communication log is handled. The channel provides functionality to handle socket join handle_joined and socket messages handle_message(msg).

Example:

class ChatChannel < Amber::Websockets::Channel
  def handle_joined(client_socket)
    # functionality when the user joins the channel, optional
  end

  def handle_leave(client_socket)
    # functionality when the user leaves the channel, optional
  end

  # functionality when a socket sends a message to a channel, required
  def handle_message(msg)
    rebroadcast!(msg)
  end
end

Constructors

new(topic_path : String)
Source

Instance methods

handle_joined(client_socket, message)

Authorization can happen here

Source
handle_leave(client_socket)
Source
handle_message(client_socket, msg)
Source
on_message(client_socket_id, message)

Called from proc when message is returned from the pubsub service

Source