@Test public void testStartTimeoutTimer() throws Exception { RequestContext requestContext = new RequestContext(null,null,null); requestContext.setOnRequestTimeoutListener(new RequestContext.OnRequestTimeoutListener() { @Override public void onRequestTimeout(RequestContext context) { timeout = true; } }); requestContext.setReadTimeout(2); assertEquals(timeout,false); requestContext.startTimeoutTimer(); assertEquals(timeout, false); Thread.sleep(2100); assertEquals(timeout, true); }
public void startTimeoutTimer() { if (timer != null) { timer.cancel(); } timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { callRequestTimeout(); } },readTimeout * 1000); }
RequestContext implements ResponseHandler { public void startTimeoutTimer() { if (timer != null) { timer.cancel(); } timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { callRequestTimeout(); } },readTimeout * 1000); } }
RequestContext implements ResponseHandler { public void startTimeoutTimer() { if (timer != null) { timer.cancel(); } timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { callRequestTimeout(); } },readTimeout * 1000); } RequestContext(Request request, Packet requestPacket, ResponseHandler responseHandler); }
RequestContext implements ResponseHandler { public void startTimeoutTimer() { if (timer != null) { timer.cancel(); } timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { callRequestTimeout(); } },readTimeout * 1000); } RequestContext(Request request, Packet requestPacket, ResponseHandler responseHandler); int getFlags(); void setFlags(int flags); Object getTag(); Packet getRequestPacket(); ResponseHandler getResponseHandler(); int getRequestCommand(); void setOnRequestTimeoutListener(OnRequestTimeoutListener listener); @Override void sendSuccessMessage(int command, ByteString requestBody, Packet packet); @Override void sendFailureMessage(int command, Throwable error); void startTimeoutTimer(); ByteString getRequestBody(); void setReadTimeout(long readTimeout); void onAddToQueue(); void onRemoveFromQueue(); Map getAttach(); Request getRequest(); void setRequestPacket(Packet requestPacket); @Override String toString(); }
RequestContext implements ResponseHandler { public void startTimeoutTimer() { if (timer != null) { timer.cancel(); } timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { callRequestTimeout(); } },readTimeout * 1000); } RequestContext(Request request, Packet requestPacket, ResponseHandler responseHandler); int getFlags(); void setFlags(int flags); Object getTag(); Packet getRequestPacket(); ResponseHandler getResponseHandler(); int getRequestCommand(); void setOnRequestTimeoutListener(OnRequestTimeoutListener listener); @Override void sendSuccessMessage(int command, ByteString requestBody, Packet packet); @Override void sendFailureMessage(int command, Throwable error); void startTimeoutTimer(); ByteString getRequestBody(); void setReadTimeout(long readTimeout); void onAddToQueue(); void onRemoveFromQueue(); Map getAttach(); Request getRequest(); void setRequestPacket(Packet requestPacket); @Override String toString(); static final int FLAG_REQUEST_ALREADY_SEND; static final int FLAG_CHECK_CONNECT_STATUS; static final int FLAG_JUMP_QUEUE; static final int FLAG_CLEAR_QUEUE; static final int FLAG_NOT_SUPPORT_REPEAT; static final int FLAG_DISALLOW_WAIT_CONNECT; }