📄 connectinfo.java
字号:
/**
*
*/
package com.aceway.vas.commons.tcp.impl;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.List;
public class ConnectInfo {
private int connectId= -1;
private ByteBuffer recvBuff = null;
private List sendDataList = new ArrayList();
private Object attachObj = null;
private SelectionKey key = null;
public void setAttachObj(Object attachObj){
this.attachObj = attachObj;
}
public Object getAttachObj(){
return this.attachObj;
}
public void setKey(SelectionKey key){
this.key = key;
}
public SelectionKey getKey(){
return this.key;
}
public ConnectInfo(int connectId, int bufferCapacity){
this.connectId = connectId;
recvBuff = ByteBuffer.allocate(bufferCapacity);
}
public int getConnectId(){
return connectId;
}
public void addSendData(byte[] bytes){
this.sendDataList.add(ByteBuffer.wrap(bytes));
}
public List getSendData(){
return this.sendDataList;
}
public SocketAddress getRemoteAddress(){
SocketChannel sc = (SocketChannel)key.channel();
return sc.socket().getRemoteSocketAddress() ;
}
public ByteBuffer getRecvBuff(){
return this.recvBuff;
}
public void setRecvBuff(ByteBuffer buff){
this.recvBuff = buff;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -