multicastserver.java

来自「这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统」· Java 代码 · 共 71 行

JAVA
71
字号
package net.sf.dz.pnp;import org.freehold.jukebox.logger.LogChannel;import org.freehold.jukebox.service.ActiveService;/** * An abstract multicast server. * * <p> * * Provides a protocol independent announcer abstraction for plug-and-play * features. * * @author Copyright &copy; <a href="mailto:vt@freehold.crocodile.org">Vadim Tkachenko</a> 2004 * @version $Id: MulticastServer.java,v 1.2 2004/06/28 20:35:49 vtt Exp $ */abstract public class MulticastServer extends ActiveService {    public static final LogChannel CH_MS = new LogChannel("MulticastServer");    private String message;    /**     * Make an announce.     *     * The message will be broadcast immediately, and then repeated     * according to predefined announce interval. If no message was supplied     * yet, no message will be broadcast.     *     * @param message Message to broadcast.     */    public final void announce(String message) {            this.message = message;    }        protected final void execute() throws Throwable {            while ( isEnabled() ) {                    try {                            if ( message != null ) {                                    complain(LOG_DEBUG, CH_MS, "Announcing: " + message);                                    announce();                }                            } catch ( Throwable t ) {                            complain(LOG_WARNING, CH_MS, "Failed to announce", t);            }            // VT: FIXME: Now, this is cruel to the network...                        Thread.sleep(5000);                    }    }        abstract protected void announce() throws Throwable;        /**     * Get the announcement message.     */    public String getMessage() {            return message;    }}

⌨️ 快捷键说明

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