drab v0.4.1 Drab.Socket

Drab operates on websockets. To enable it, you should inject the Drab.Channel into your Socket module (by default it is UserSocket in web/channels/user_socket.ex):

defmodule MyApp.UserSocket do
  use Phoenix.Socket
  use Drab.Socket
end

This creates a channel “__drab:*” used by all Drab operations.

You may create your own channels inside a Drab Socket, but you can’t provide your own connect callback. Drab Client (on JS side) always connects at the page load and Drab’s built-in connect callback will intercept this call. If you want to pass the parameters to the Channel, you may do it in Drab.Client.js, they will appear in Socket’s assigns. Please visit Drab.Client to learn more.

Drab uses the socket which is defined in your application Endpoint (default lib/endpoint.ex) By default, Drab uses “/socket” as a path. In case of using different one, configure it with:

config :drab, 
  socket: "/my/socket"