📄 rooms.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.server.remote.ChatClient;import com.lyrisoft.chat.server.remote.ChatServer;import com.lyrisoft.chat.server.remote.IAuthenticator;import com.lyrisoft.chat.server.remote.RoomServer;import com.lyrisoft.chat.ICommands;public class Rooms implements ICommandProcessorRemote { public boolean process(ChatClient client, String[] args) { ChatServer server = client.getServer(); String[] roomNames = server.getRoomNames(); for (int i=0; i < roomNames.length; i++) { String name = roomNames[i];// RoomServer room = server.getRoom(name);// int count = room.getUserCount(); int count = server.getUserCountInRoom(name); roomNames[i] = name + ICommands.DELIMITER + count; } client.roomList(roomNames); return false; } // NOTE: when processing distributed style, the message contains information // (not a request for a user list) public void processDistributed(String client, String origin, String[] args, ChatServer server) { /** * Ok, this is a strange case. Currently, according to the protocol, a roomlist is always * followed by messages that describe the state of each room (in the form of /join commands). * * Those join commands are sufficient to populate the local state table, since a room * can only exist if it's non-empty * * Therefore, there is no implementation here. We just return. The UsersInRoom processor * will end up getting invoked, and we'll get the list of rooms that way. */ } public String getHelp() { return Translator.getMessage("help.rooms"); } public int accessRequired() { return IAuthenticator.USER; } public String getUsage(String myName) { return Translator.getMessage("usage1", myName); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -