View Javadoc

1   /*
2    * AI Soccer Project - network gaming environment for AI warriors.
3    * Copyright (C) 2001-2004  Marcin Werla, Pawel Widera
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU General Public License
7    * as published by the Free Software Foundation; either version 2
8    * of the License, or (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, you can find it here:
17   * http://www.gnu.org/licenses/gpl.html
18   */
19  
20  package snifos.communication;
21  
22  import org.dom4j.Document;
23  
24  import snifos.common.UserId;
25  
26  import snifos.exception.InvalidUserException;
27  
28  import snifos.server.Server;
29  
30  import java.util.Properties;
31  
32  
33  /***
34   * This interface describes communication module which can
35   * be used in SNIFOS application server.
36   * @version $Id: CommModule.java,v 1.2 2004/05/08 21:55:25 mwerla Exp $
37   */
38  public interface CommModule extends Runnable {
39      /***
40       * Configures instance of CommModule with given parameters.
41       * @param configuration Configuration which will be used.
42      * @param commModuleId Id of this instance of communication module
43      * inside the server - it is necessary to create valid user id.
44       */
45      public void configure(Properties configuration, int commModuleId);
46  
47      /***
48       * Sets instance of server which will be
49       * used to pass messages to applications.
50       * @param server Server instance.
51       */
52      public void setServer(Server server);
53  
54      /***
55       * Called by server to send message to user.
56       * @param userId Id of user which should receive message.
57       * @param message Message to be sent.
58      * @throws InvalidUserException Thrown when user id is invalid for this
59      * communication module instance.
60       */
61      public void sendMessage(UserId userId, Document message)
62          throws InvalidUserException;
63  
64      /***
65       * Disconnects given user from a module.
66       * @param userId User id.
67       */
68      public void disconnectUser(UserId userId);
69  
70      /***
71       * Stops communication module.
72       */
73      public void shutdown();
74  }