View Javadoc
1   /******************************************************************************
2    * ClientAdapter.java - Hook up the network to the application
3    * $Id$
4    * 
5    * BuckoFIBS - Backgammon by BuckoSoft
6    * Copyright(c) 2009,2010 - Dick Balaska - BuckoSoft, Corp.
7    * 
8    * $Log$
9    * Revision 1.5  2013/09/25 03:22:38  dick
10   * words.
11   *
12   * Revision 1.4  2011/05/22 05:48:15  dick
13   * Point to the "new" cvs location.
14   *
15   * Revision 1.3  2010/03/03 13:12:21  inim
16   * Replaced (c) sign in comment mangled by CVS default encoding back to UTF-8
17   *
18   * Revision 1.2  2010/03/03 12:19:49  inim
19   * Moved source to UTF8 encoding from CP1252 encoding. To this end all source files' (c) message was updated to "Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.". This replaces the (c) sign to UTF8, and adds the new year 2010.
20   *
21   * Revision 1.1  2010/02/04 05:57:53  inim
22   * Mavenized project folder layout
23   *
24   * Revision 1.4  2009/02/24 05:33:27  dick
25   * Add connectionAborted() for when the socket crashes.
26   *
27   * Revision 1.3  2009/02/14 12:27:44  dick
28   * BuckoFIBS is released under the GNU license.
29   *
30   * Revision 1.2  2009/01/26 17:35:15  dick
31   * Push the CookieMonster down to the ClientConnection.  ClientAdapter now emits the cookie with the string.
32   * There are many messages besides the known "BadBoard" messages that are a result of runon messages (missing crlf).
33   * CookieMonster is going to need to do a full regexp scan and see if there is anything on the right that needs to be pushed back as another message.
34   *
35   * Revision 1.1  2009/01/12 07:45:47  dick
36   * Hook up the network to the application.
37   *
38   */
39  
40  /* 
41   * This program is free software: you can redistribute it and/or modify
42   * it under the terms of the GNU General Public License as published by
43   * the Free Software Foundation, either version 3 of the License, or
44   * (at your option) any later version.
45   *
46   * This program is distributed in the hope that it will be useful,
47   * but WITHOUT ANY WARRANTY; without even the implied warranty of
48   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
49   * GNU General Public License for more details.
50   *
51   * You should have received a copy of the GNU General Public License
52   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
53   *
54   * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>.
55   * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp.
56   * 
57   */
58  package com.buckosoft.fibs.net;
59  
60  /** Hook up the network to the application.
61   * 
62   * @author Dick Balaska
63   * @since 2009/01/11
64   * @version $Revision$ <br> $Date$
65   * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/main/java/com/buckosoft/fibs/net/ClientAdapter.java">cvs ClientAdapter.java</a>
66   */
67  public interface ClientAdapter {
68  	/** Define what kind of message this is
69  	 */
70  	enum MessageRoute {
71  		NETWORKOUT,
72  		SYSTEM,
73  		ERROR,
74  		DEBUG
75  	}
76  
77  	/** Write a message
78  	 * @param route What kind of message is this
79  	 * @param s The message to write
80  	 */
81  	void writeSystemMessage(MessageRoute route, String s);
82  
83  	/** Write a message with an eol at the end
84  	 * @param route What kind of message is this
85  	 * @param s The message to write
86  	 */
87  	void writeSystemMessageln(MessageRoute route, String s);
88  
89  	/** Dispatch a received message (line) from FIBS
90  	 * @param cookie The parsed {@link FIBSMessages} cookie
91  	 * @param s The line received
92  	 */
93  	void dispatch(int cookie, String s);
94  	
95  	/** Callback when the network connection to FIBS terminated unexpectedly
96  	 */
97  	void connectionAborted();
98  }