Skip to content

Instantly share code, notes, and snippets.

@phuesler
Created February 7, 2013 10:54
Show Gist options
  • Save phuesler/4730273 to your computer and use it in GitHub Desktop.
Save phuesler/4730273 to your computer and use it in GitHub Desktop.
handle_info(tick, State) ->
Now = now(),
Waiting = lists:map(fun ({GameId, WantedPlayers, Players}) ->
{GameId, WantedPlayers,
lists:filter(fun ({_, _, _, Start, _}) ->
timer:now_diff(Now, Start) > 60000
end, Players)}
end, State#state.waiting),
NewWaiting = lists:filter(fun ({_, _, []}) -> false;
(_) -> true
end, Waiting),
erlang:send_after(1000, self(), tick),
{noreply, State#state{waiting = NewWaiting}};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment