use of com.generallycloud.baseio.component.Parameters in project baseio by generallycloud.
the class MapByteMessageDecoder method decode.
@Override
public Message decode(ParamedProtobaseFuture future) {
Parameters param = future.getParameters();
String messageId = param.getParameter("msgId");
String queueName = param.getParameter("queueName");
JSONObject map = param.getJSONObject("map");
byte[] array = future.getReadBinary();
return new MapByteMessage(messageId, queueName, map, array);
}
use of com.generallycloud.baseio.component.Parameters in project baseio by generallycloud.
the class TextMessageDecoder method decode.
@Override
public Message decode(ParamedProtobaseFuture future) {
Parameters param = future.getParameters();
String messageId = param.getParameter("msgId");
String queueName = param.getParameter("queueName");
String text = param.getParameter("text");
return new TextMessage(messageId, queueName, text);
}
use of com.generallycloud.baseio.component.Parameters in project baseio by generallycloud.
the class RTPServerDPAcceptor method execute.
@Override
protected void execute(DatagramSession dSession, DatagramRequest request) {
String serviceName = request.getFutureName();
if (BIND_SESSION.equals(serviceName)) {
Parameters parameters = request.getParameters();
ApplicationContext context = ApplicationContext.getInstance();
LoginCenter loginCenter = AuthorityContext.getInstance().getLoginCenter();
if (!loginCenter.isValidate(parameters)) {
return;
}
// FIXME udp
SocketChannelContext channelContext = context.getChannelContext();
SocketSessionManager sessionManager = channelContext.getSessionManager();
// Session session = factory.getSession(username);
SocketSession session = null;
if (session == null) {
return;
}
// session.setDatagramChannel(channel); //FIXME udp
ProtobaseFuture future = new ProtobaseFutureImpl(session.getContext(), BIND_SESSION_CALLBACK);
logger.debug("___________________bind___session___{}", session);
future.write("1");
session.flush(future);
} else {
logger.debug(">>>> {}", request.getFutureName());
}
}
use of com.generallycloud.baseio.component.Parameters in project baseio by generallycloud.
the class FileReceiveUtil method accept.
public void accept(SocketSession session, ParamedProtobaseFuture future, boolean callback) throws Exception {
Parameters parameters = future.getParameters();
OutputStream outputStream = (OutputStream) session.getAttribute(ACCEPT_FILE);
if (outputStream == null) {
String fileName = prefix + parameters.getParameter(FILE_NAME);
outputStream = new FileOutputStream(new File(fileName));
session.setAttribute(ACCEPT_FILE, outputStream);
logger.info("accept...................open,file={}", fileName);
}
byte[] data = future.getReadBinary();
outputStream.write(data, 0, future.getReadBinarySize());
logger.info("accept...................{},{}", future.getReadBinarySize(), (num++));
boolean isEnd = parameters.getBooleanParameter(IS_END);
if (isEnd) {
logger.info("accept...................close,stream={}", outputStream);
CloseUtil.close(outputStream);
session.removeAttribute(ACCEPT_FILE);
if (callback) {
future.write("传输成功!");
session.flush(future);
}
}
}
use of com.generallycloud.baseio.component.Parameters in project baseio by generallycloud.
the class AuthorityFilter method accept.
@Override
protected void accept(SocketSession session, NamedFuture future) throws Exception {
AuthorityContext authorityContext = AuthorityContext.getInstance();
AuthoritySessionAttachment attachment = authorityContext.getSessionAttachment(session);
AuthorityManager authorityManager = attachment.getAuthorityManager();
if (authorityManager == null) {
RoleManager roleManager = authorityContext.getRoleManager();
authorityManager = roleManager.getAuthorityManager(Authority.GUEST);
attachment.setAuthorityManager(authorityManager);
}
if (!authorityManager.isInvokeApproved(future.getFutureName())) {
future.write(RESMessage.UNAUTH.toString());
session.flush(future);
String futureName = future.getFutureName();
String remoteAddr = session.getRemoteAddr();
String readText = future.getReadText();
if (!StringUtil.isNullOrBlank(readText)) {
logger.info("refuse connection, ip:{}, service name:{}, content: {}", new String[] { remoteAddr, futureName, readText });
return;
}
if (future instanceof ParametersFuture) {
Parameters parameters = ((ParametersFuture) future).getParameters();
if (parameters.size() > 0) {
logger.info("refuse connection, ip:{}, service name:{}, content: {}", new String[] { remoteAddr, futureName, parameters.toString() });
return;
}
}
logger.info("refuse connection, ip:{}, service name:{}", remoteAddr, futureName);
}
}
Aggregations