iserverlistener.java

来自「Bluetooth chat Server and Client in j2」· Java 代码 · 共 83 行

JAVA
83
字号
/* The Bluetooth Library for client-server communication Copyright (C) 2006 Martin Vysny This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. */package net.sf.btw.btlib;import java.io.DataInputStream;/** * <p> * Server uses this interface to notify listener about events. * </p> * <p> * Generally, event handlers should not fire an exception while in the handler. * If an exception is thrown, it is logged and * {@link IErrorListener#errorOccured(byte, int, boolean, Exception)} is called. * If the exception is thrown while a connection is being created the connection * will be destroyed. * </p> *  * @author Martin Vysny *  */public interface IServerListener extends IErrorListener {	/**	 * New client has connected to the server. In this phase you may send	 * packets.	 * 	 * @param id	 *            new ID of the client	 * @param name	 *            client's device name.	 */	void clientConnected(final byte id, final String name);	/**	 * A client has disconnected.	 * 	 * @param id	 *            id of the client.	 * @param name	 *            client's device name.	 */	void clientDisconnected(final byte id, final String name);	/**	 * <p>	 * A message has arrived from client. You may read the message from the	 * stream, or you may use the byte array. You must NOT block in this method -	 * no packets are received until this method finishes.	 * </p>	 * <p>	 * Warning: you should not close the stream - the stream cannot be reused	 * when closed.	 * </p>	 * 	 * @param clientID	 *            message arrived from this client.	 * @param name	 *            client's device name.	 * @param message	 *            the message contents.	 * @param messageLength	 *            the length of data contained in the message array	 * @param stream	 *            stream reading bytes from the message, initially positioned	 *            over the first byte of the message.	 */	void messageArrived(final byte clientID, final String name, byte[] message,			int messageLength, DataInputStream stream);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?