Commits

Fred T-H committed cd3e531

fixing comments in client module

  • Participants
  • Parent commits 2bd9a7c

Comments (0)

Files changed (1)

 -define(SESSION_LIFE, 15000).
 -define(LISTEN_TIMEOUT, 40000).
 
-%% start/connect a user
+%%--------------------------------------------------------------------
+%% Function: connect(Id) -> {ok, HandlerId}.
+%% Description: Let's a client initiate a connection to some user.
+%% If the user doesn't exist, it should be started, otherwise the
+%% client connects normally.
+%% The client should keep track of the HandlerId as it acts a bit as
+%% its session ID for a given user.
+%%--------------------------------------------------------------------
 connect(Id) ->
     usr:start(Id, ?SESSION_LIFE),
     usr:subscribe(Id).
 
-%% leaves the user
-disconnect(Id, Handler) ->
-    usr:unsubscribe(Id, Handler).
+%%--------------------------------------------------------------------
+%% Function: disconnect(Id, HandlerId) -> ok
+%% Description: Removes a client's listener from a given user.
+%%--------------------------------------------------------------------
+disconnect(Id, HandlerId) ->
+    usr:unsubscribe(Id, HandlerId).
 
-%% send a message to another user
+%%--------------------------------------------------------------------
+%% Function: message(From, To, Message) -> ok
+%% Description: Sends a message from a given user to another one
+%%--------------------------------------------------------------------
 message(From, To, Message) ->
     usr:message(From, To, Message).
 
-%% picks messages belonging to Id
+%%--------------------------------------------------------------------
+%% Function: listen(Id, HandlerId) -> [Message]
+%% Description: Fetches messages belonging to user Id from HandlerId.
+%% If the user has been terminated for some reason, there will be
+%% an exit exception raised.
+%%--------------------------------------------------------------------
 listen(Id, HandlerId) ->
     receive
         {{Id, HandlerId}, Msg} -> [Msg | listen1(Id, HandlerId)];
         []
     end.
 
-%% used to catch all messages currently lined up
 listen1(Id, HandlerId) ->
     receive
         {{Id, HandlerId}, Msg} -> [Msg | listen1(Id, HandlerId)]