Advertisement
Guest User

Untitled

a guest
Mar 16th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.42 KB | None | 0 0
  1. %% @doc: Find a cell to serve user, and try to spawn new if that's not found
  2. find_cell(UserId, WorldId) ->
  3.   case pick_cell(UserId, WorldId, 0) of
  4.     {ok, Pid} -> {ok, Pid};
  5.     {error, _} ->
  6.       try
  7.         gen_server:cast(?SERVER, {spawn_cell, UserId, WorldId}),
  8.         timer:sleep(?WAIT_TIMEOUT),
  9.         pick_cell(UserId, WorldId, 0)
  10.       catch
  11.         exit:{timeout, _} -> {error, not_found}
  12.       end
  13.   end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement