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.server;
21  
22  import org.dom4j.Document;
23  
24  import snifos.common.UserId;
25  
26  import snifos.exception.ConfigurationException;
27  import snifos.exception.InvalidUserException;
28  
29  
30  /***
31   * This interface describes class which can be used to run SNIFOS applications
32   * and communication modules server.
33   * @version $Id: Server.java,v 1.2 2004/05/08 21:55:29 mwerla Exp $
34   */
35  public interface Server extends Runnable {
36      /***
37       * Called by application to send message to user.
38       * @param userId Id of user which should receive message.
39       * @param message Message to be sent.
40       */
41      public void sendMessage(UserId userId, Document message);
42  
43      /***
44       * Called by communication module to pass message from user
45       * to appropriate application.
46       * @param userId Id of user which sends message.
47       * @param message Received message.
48       * @throws InvalidUserException Thrown when user id is invalid.
49      * @throws ConfigurationException Thrown when application instance with
50      * default configuration is created and the configuration is invalid.
51       */
52      public void receiveMessage(UserId userId, Document message)
53          throws InvalidUserException, ConfigurationException;
54  
55      /***
56       * Disconnects user with given id from server.
57       * @param userId Id of the user.
58       */
59      public void disconnectUser(UserId userId);
60  
61      /***
62       * Unregisters user with given id from server application.
63       * @param userId Id of the user.
64       */
65      public void unregisterUser(UserId userId);
66  }