     end
   end
 
+  @doc """
+  The handle function can receive the following requests:
+
+  * pusher:subscribe
+  * pusher:unsubscribe
+  * pusher:ping
+  * client-* event
+
+  More info: http://pusher.com/docs/pusher_protocol
+  """
   def websocket_handle({:text, json}, req, state) do
     JSX.decode!(json) |> handle_pusher_event(req, state)
   end
 
-  def handle_pusher_event(decoded_json, req, state) do
+  defp handle_pusher_event(decoded_json, req, state) do
     handle_pusher_event(decoded_json["event"], decoded_json, req, state)
   end
 

    defstruct [:socket_id, :time]
  end

  def init(_transport, _req, _opts), do: {:upgrade, :protocol, :cowboy_websocket}

  def websocket_init(_transport_name, req, _opts) do
    {app_key, req} = :cowboy_req.binding(:app_key, req)
    {protocol, req} = :cowboy_req.qs_val("protocol", req, to_string(@max_protocol))

    {:ok, req, state}
  end

  @doc """
  This function handles 3 possible cases:

  * start - Normal start after successful websocket_init
  * start_error - Improper start returning useful error code after unsuccessful websocket_init
  * msg broadcast - Any message generate by events that gets to the connection
  """
  def websocket_info(:start, req, _state) do
    # Unique identifier for the connection
    socket_id = SocketId.generate!
