Fri Feb 04, 2011 5:08 pm
/*
JM2PC - Java Mobile to PC
Copyright (C) 2005-2009 - Walter Alves Wanderley
Recife - PE - Brazil
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 3 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package jm2pc.server.connection;
import java.util.Date;
import jm2pc.server.i18n.Messages;
import jm2pc.server.log.Loggable;
import jm2pc.server.utils.DateFormat;
public abstract class ServerManager {
private int timeout;
private String password;
private boolean serverStarted;
private Loggable log;
private int clientNumber;
public ServerManager(Loggable log) {
serverStarted = false;
this.log = log;
clientNumber = 0;
}
protected String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getTimeout() {
return timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
public boolean isServerStarted() {
return serverStarted;
}
public void setServerStarted(boolean serverStarted) {
this.serverStarted = serverStarted;
}
public Loggable getLog() {
return log;
}
public void setLog(Loggable log) {
this.log = log;
}
public void showStartMessage(String type) {
StringBuffer sb = new StringBuffer(type + " -- ");
sb.append(" Timeout = " + getTimeout() + "min");
sb.append('\n');
sb.append(Messages.getMessage("serverStartAt") + ": " + new Date());
sb.append('\n');
sb.append('\n');
sb.append(Messages.getMessage("waitClients") + "...");
sb.append('\n');
sb.append("-------------------------------");
log.logSucess(sb.toString());
}
public void showDisconnectMessage(int connectedCount) {
if(connectedCount == 1)
log.logSucess(Messages.getMessage("disconnect") + " " + connectedCount + " " + Messages.getMessage("client"));
else
log.logSucess(Messages.getMessage("disconnect") + " " + connectedCount + " " + Messages.getMessage("clients"));
}
public void showStoppedMessage() {
log.logSucess("*******************************************");
log.logSucess(DateFormat.format(new Date()) + " -> " + Messages.getMessage("serverStopped"));
log.logSucess("*******************************************");
}
public void incrementClientNumber() {
clientNumber++;
}
public int getClientNumber() {
return clientNumber;
}
public void setClientNumber(int clientNumber) {
this.clientNumber = clientNumber;
}
public abstract void start() throws Exception;
public abstract void stop() throws Exception;
}
Sat Feb 05, 2011 12:13 am
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.