📄 ping.java
字号:
/* * Copyright (c) 2000 Lyrisoft Solutions, Inc. * Used by permission */package com.lyrisoft.chat.server.remote.command;import com.lyrisoft.chat.Translator;import com.lyrisoft.chat.ICommands;import com.lyrisoft.chat.Constants;import com.lyrisoft.chat.server.remote.ChatClient;import com.lyrisoft.chat.server.remote.ChatServer;import com.lyrisoft.chat.server.remote.IAuthenticator;public class Ping implements ICommandProcessorRemote, Constants, ICommands { public boolean process(ChatClient client, String[] args) { if (args.length < 3) { client.generalError(getUsage(args[0])); return false; } else { if (args[1].equals(SERVER_NAME)) { client.pong(SERVER_NAME, args[2]); return false; } else { ChatClient otherClient = client.getServer().getClient(args[1]); if (otherClient == null) { if (!client.getServer().userExists(args[1])) { client.error(NO_SUCH_USER, args[1]); return false; } return true; } else { otherClient.ping(client.getUserId(), args[2]); return false; } } } } public void processDistributed(String client, String origin, String[] args, ChatServer server) { if (args.length < 3) { // this message does not obey protocol. oh well, just return System.err.println("args < 3"); return; } if (args[1].equalsIgnoreCase(server.getName())) { ChatServer.log("Ping from " + origin); // ping from a server server.sendServerPong(origin, args[2]); } else { // ping from a user ChatClient otherClient = server.getClient(args[1]); if (otherClient != null) { otherClient.ping(client, args[2]); } } } public String getHelp() { return Translator.getMessage("help.ping"); } public int accessRequired() { return IAuthenticator.USER; } /** * Even though this command takes an argument, it is not displayed in the usage, * since the argument is the current time and the gui automatically adds it. */ public String getUsage(String myName) { return Translator.getMessage("usage2", myName, "<user>"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -