Skip to content

Commit

Permalink
Add missing clause to handle pings on WebsocketHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
edgurgel committed Jul 6, 2015
1 parent 909ac30 commit d42b25f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/poxa/websocket_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ defmodule Poxa.WebsocketHandler do
def websocket_handle({:text, json}, req, state) do
JSX.decode!(json) |> handle_pusher_event(req, state)
end
def websocket_handle({:ping, _}, req, state), do: { :ok, req, state }

defp handle_pusher_event(decoded_json, req, state) do
handle_pusher_event(decoded_json["event"], decoded_json, req, state)
Expand Down
5 changes: 5 additions & 0 deletions test/websocket_handler_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ defmodule Poxa.WebsocketHandlerTest do
assert websocket_info(nil, :req, :state) == {:ok, :req, :state}
end

test "ping websocket message" do
assert websocket_handle({:ping, ""}, :req, :state) ==
{:ok, :req, :state}
end

test "undefined pusher event websocket message" do
expect(JSX, :decode!, 1, %{"event" => "pushernil"})

Expand Down

0 comments on commit d42b25f

Please sign in to comment.