📄 crystalevent.java
字号:
/*
* Created on 2005-6-30
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.swing.game.crystal;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import com.swing.server.common.GameEvent;
/**
* @author vampire_a
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class CrystalEvent implements GameEvent {
/** playerID that sent the message (for client mesgs) */
protected String playerId;
/** gameID that the event belongs to, if any */
protected String gameCode;
/** chat message or other command specific string */
protected String request;
protected List response = new ArrayList();
/** 请求类型
* SOCKET : 0
* POST : 1
* GET : 2
* OTHER : 3
*/
protected int kind;
public CrystalEvent ()
{
}
/* (non-Javadoc)
* @see com.swing.server.common.GameEvent#getGameCode()
*/
public String getGameCode() {
// TODO Auto-generated method stub
return this.gameCode;
}
/* (non-Javadoc)
* @see com.swing.server.common.GameEvent#setGameCode(java.lang.String)
*/
public void setGameCode(String gameCode) {
// TODO Auto-generated method stub
this.gameCode = gameCode;
}
/* (non-Javadoc)
* @see com.swing.server.common.GameEvent#getKind()
*/
public int getKind() {
// TODO Auto-generated method stub
return this.kind;
}
/* (non-Javadoc)
* @see com.swing.server.common.GameEvent#setKind(int)
*/
public void setKind(int kind) {
// TODO Auto-generated method stub
this.kind = kind;
}
/* (non-Javadoc)
* @see com.swing.server.common.GameEvent#getPlayerId()
*/
public String getPlayerId() {
// TODO Auto-generated method stub
return playerId;
}
/* (non-Javadoc)
* @see com.swing.server.common.GameEvent#setPlayerId(java.lang.String)
*/
public void setPlayerId(String id) {
// TODO Auto-generated method stub
this.playerId = id;
}
/* (non-Javadoc)
* @see com.swing.server.common.GameEvent#read(java.nio.ByteBuffer)
*/
public void read(ByteBuffer buff) {
byte [] t = new byte[buff.remaining()];
String [] tt = null;
try {
buff.get(t);
request = new String(t, "UTF-8");
// 这里的区分符'应该用配置文件里的!!!
tt = request.split(CrystalController.SPLITTER_1);
this.playerId = tt[0];
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
t = null;
tt = null;
}
}
/* (non-Javadoc)
* @see com.swing.server.common.GameEvent#write(java.nio.ByteBuffer)
*/
public int write(ByteBuffer buff) {
// TODO Auto-generated method stub
return 0;
}
/* (non-Javadoc)
* @see com.swing.server.common.GameEvent#getRequest()
*/
public String getRequest() {
// TODO Auto-generated method stub
return request;
}
/* (non-Javadoc)
* @see com.swing.server.common.GameEvent#setRequest(java.lang.String)
*/
public void setRequest(String request) {
// TODO Auto-generated method stub
this.request = request;
}
/* (non-Javadoc)
* @see com.swing.server.common.GameEvent#getResponse()
*/
public List getResponse() {
// TODO Auto-generated method stub
return response;
}
/* (non-Javadoc)
* @see com.swing.server.common.GameEvent#addResponse(java.lang.Object)
*/
public void addResponse(Object message) {
// TODO Auto-generated method stub
this.response.add(message);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -