   # -------------------------------------------------------------------
 
   defp connect(%{transport_pid: nil} = state) do
-    {:ok, transport_pid} = state.transport.start_link(state.url)
+    {:ok, transport_pid} = state.transport_mod.start_link(state.url)
     transport_mref = Process.monitor(transport_pid)
     %{state | transport_pid: transport_pid, transport_mref: transport_mref}
   end

  # -------------------------------------------------------------------

  @doc false
  def init({callback, transport, arg, socket_opts}) do
    case callback.init(arg) do
      {:ok, url, callback_state} ->
        {:ok, %{
          url: url,
          transport: transport,
          serializer: Keyword.get(socket_opts, :serializer, Phoenix.Channels.GenSocketClient.Serializer.Json),
          callback: callback,
          callback_state: callback_state,


  @type socket_opts :: [{:serializer, module}]
  @type callback_state :: any
  @opaque transport :: %{
    transport_mod: module,
    transport: pid | nil,
    message_refs: :ets.tab,
    serializer: module
  }
  @type topic :: String.t
  @type event :: String.t
  @type payload :: %{String.t => any}
