Advertisement
Guest User

Untitled

a guest
Mar 16th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.49 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.         case gen_server:cast(?SERVER, {spawn_cell, UserId, WorldId}) of
  8.           ok -> pick_cell(UserId, WorldId, ?WAIT_TIMEOUT), pick_cell(UserId, WorldId, ?WAIT_TIMEOUT);
  9.           Error -> Error
  10.         end
  11.       catch
  12.         exit:{timeout, _} -> {error, not_found}
  13.       end
  14.   end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement