       :ok
 
   """
-  def broadcast_from(socket, event, message) do
+  def broadcast_from(%Socket{} = socket, event, message) do
     %{pubsub_server: pubsub_server, topic: topic, transport_pid: transport_pid} = socket
     Server.broadcast_from pubsub_server, transport_pid, topic, event, message
   end


  """
  @spec push(Socket.t, String.t, map()) :: reference()
  def push(socket, event, payload \\ %{}) do
    ref = make_ref()
    send(socket.channel_pid,
         %Message{event: event, topic: socket.topic, ref: ref, payload: __stringify__(payload)})

  Emulates the client leaving the channel.
  """
  @spec leave(Socket.t) :: reference()
  def leave(%Socket{} = socket) do
    push(socket, "phx_leave", %{})
  end

