//
//
/**将{@link RequestSocketBlock}转换为{@link RequestMsg}消息。*/
public static RequestMsg requestToMessage(RequestSocketBlock block) {
//1.基本参数
RequestMsg reqMetaData = new RequestMsg();
reqMetaData.setVersion(block.getVersion());//协议版本
reqMetaData.setRequestID(block.getRequestID());//请求ID
reqMetaData.setServiceName(getString(block, block.getServiceName()));//远程服务名
reqMetaData.setServiceGroup(getString(block, block.getServiceGroup()));//远程服务分组
reqMetaData.setServiceVersion(getString(block, block.getServiceVersion()));//远程服务版本
reqMetaData.setTargetMethod(getString(block, block.getTargetMethod()));//远程服务方法名
reqMetaData.setSerializeType(getString(block, block.getSerializeType()));//序列化策略
reqMetaData.setClientTimeout(block.getClientTimeout());//远程客户端超时时间
//2.调用参数
short[] pTypes = block.getParameterTypes();
short[] pValues = block.getParameterValues();
for (int i = 0; i < pTypes.length; i++) {
String paramType = getString(block, pTypes[i]);
byte[] rawData = block.readPool(pValues[i]);
//
reqMetaData.addParameter(paramType, rawData);
}
//3.Opt参数
short[] oTypes = block.getOptionKeys();
short[] oValues = block.getOptionValues();
for (int i = 0; i < oTypes.length; i++) {
String optKey = getString(block, oTypes[i]);
String optVar = getString(block, oValues[i]);
//
reqMetaData.addOption(optKey, optVar);
}
return reqMetaData;
};