use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.
the class EzySimpleDataHandler method handleRequest.
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void handleRequest(EzyConstant cmd, EzyArray data) {
try {
EzyRequest request = newRequest(cmd, data);
try {
EzyInterceptor interceptor = controllers.getInterceptor(cmd);
interceptor.intercept(context, request);
EzyController controller = controllers.getController(cmd);
controller.handle(context, request);
} finally {
request.release();
}
} catch (Exception e) {
if (context != null) {
Throwable throwable = requestHandleException(session, cmd, data, e);
context.handleException(Thread.currentThread(), throwable);
} else {
if (active) {
logger.warn("fatal error, please add an issue to ezyfox-server github " + "with log: {}\nand stacktrace: ", this, e);
} else {
logger.warn("can't handle command: {} and data: {}, this session " + "maybe destroyed (session: {}), error message: {}", cmd, data, session, e.getMessage());
}
}
}
}
use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.
the class EzySocketRequestHandler method handleEvent.
@Override
public void handleEvent() {
EzySocketRequest request = null;
try {
EzySession session = sessionTicketsQueue.take();
EzyRequestQueue requestQueue = getRequestQueue(session);
// noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (requestQueue) {
request = requestQueue.take();
if (requestQueue.size() > 0) {
sessionTicketsQueue.add(session);
}
}
processRequest(request);
} catch (InterruptedException e) {
logger.info("{}-request-handler thread interrupted", getRequestType());
} catch (Throwable throwable) {
logger.warn("problems in {}-request-handler", getRequestType(), throwable);
} finally {
if (request != null) {
request.release();
}
}
}
use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.
the class EzySessionTicketsRequestQueues method addRequest.
public boolean addRequest(EzySocketRequest request) {
EzyRequestQueue queue;
EzySessionTicketsQueue ticketsQueue;
EzySession session = request.getSession();
if (request.isSystemRequest()) {
ticketsQueue = systemQueue;
queue = session.getSystemRequestQueue();
} else {
ticketsQueue = extensionQueue;
queue = session.getExtensionRequestQueue();
}
boolean success;
// noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (queue) {
boolean empty = queue.isEmpty();
success = queue.add(request);
if (empty && success) {
ticketsQueue.add(session);
}
}
return success;
}
use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.
the class EzyRawBytesInterceptorTest method test2.
@Test(expectedExceptions = EzyNotAuthorizedException.class)
public void test2() throws Exception {
EzyRawBytesInterceptor interceptor = new EzyRawBytesInterceptor();
EzyServerContext serverContext = mock(EzyServerContext.class);
EzyStreamingRequest request = new EzySimpleStreamingRequest();
interceptor.intercept(serverContext, request);
}
use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.
the class EzyRawBytesInterceptorTest method test.
@Test
public void test() throws Exception {
EzyRawBytesInterceptor interceptor = new EzyRawBytesInterceptor();
EzyServerContext serverContext = mock(EzyServerContext.class);
EzySimpleStreamingRequest request = new EzySimpleStreamingRequest();
request.setUser(new EzySimpleUser());
interceptor.intercept(serverContext, request);
}
Aggregations