package com.ld.igds.protocol.quantity.shuhan.command;
|
|
import com.ld.igds.io.constant.ProtocolEnum;
|
import com.ld.igds.protocol.quantity.shuhan.server.ShuhanServerEngine;
|
import com.ld.io.api.InvokeResult;
|
import com.ld.io.api.IoSession;
|
|
public class BaseRemoteImpl {
|
|
public String getProtocol() {
|
return ProtocolEnum.TCP_SHUHAN_V1.getCode();
|
}
|
|
/**
|
* 发送命令
|
*
|
* @param ip
|
* @param port
|
* @param msg
|
* @return
|
*/
|
public InvokeResult send(String ip, int port, byte[] msg) {
|
IoSession session = ShuhanServerEngine.getSession(ip,port);
|
if (null == session) {
|
return InvokeResult.CHANNEL_CLOSED;
|
}
|
return session.invoke(msg);
|
}
|
|
public static void updateSession(String ip, int port, String companyId) {
|
IoSession ioSession = ShuhanServerEngine.getSession(ip,port);
|
if(null != ioSession){
|
ioSession.setCompanyId(companyId);
|
}
|
}
|
|
public static InvokeResult destroy(String ip, int port) {
|
IoSession session = ShuhanServerEngine.getSession(ip,port);
|
if (null == session) {
|
return InvokeResult.SUCCESS;
|
}
|
// 执行连接销毁
|
session.destroy();
|
return InvokeResult.SUCCESS;
|
}
|
}
|