changenicknameaction.java

来自「flex实现的前台」· Java 代码 · 共 41 行

JAVA
41
字号
/**
 * 
 */
package cn.humanmonth.chat.server.protocol.requestaction;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.humanmonth.chat.server.domain.RequestData;
import cn.humanmonth.chat.server.protocol.Protocol;
import cn.humanmonth.chat.server.protocol.RequestAction;
import cn.humanmonth.chat.server.protocol.response.SendALlUserList;
import cn.humanmonth.chat.server.protocol.response.SendMsgToAll;

/**
 * @author Piterlin 
 * 
 * 处理用户更改用户呢称的请求
 */
public class ChangeNickNameAction implements RequestAction {

	private Log log=LogFactory.getLog(this.getClass());
	
	private static String action = "changeNickname";
	
	private SendALlUserList sendAllUserList = new SendALlUserList();
	
	private SendMsgToAll sendMsgToAll=new SendMsgToAll();
	public boolean canDeal(RequestData requestData) {
		log.info("changeNaickName被调用,请求的action为:"+requestData.getCAction());
		return action.equals(requestData.getCAction());
	}

	public void dealReqeust(RequestData requestData, Protocol protocol) {
		protocol.getUser().setNickName(requestData.getRequestString());
		this.sendAllUserList.deal(protocol);
		this.sendMsgToAll.sendSystemMsg("用户“"+protocol.getUser().getUserNameDetail()+"”更改了昵称", protocol);
	}

}

⌨️ 快捷键说明

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