public static void publishArrayResponse(int requestContext, int sequence, int status, Pipe<ServerResponseSchema> localOutput, long channelId, byte[] typeBytes, int contentLength, byte[] contentBacking, int contentPosition, int contentMask) { int channelIdHigh = (int)(channelId>>32); int channelIdLow = (int)channelId; publishArrayResponse(requestContext, sequence, status, localOutput, channelIdHigh, channelIdLow, typeBytes, contentLength, contentBacking, contentPosition, contentMask); }
public static void publishStatus(int sequence, int status, int channelIdHigh, int channelIdLow, Pipe<ServerResponseSchema> localOutput) { int contentLength = 0; byte[] contentBacking = null; int contentPosition = 0; int contentMask = Integer.MAX_VALUE; publishArrayResponse(ServerCoordinator.END_RESPONSE_MASK, sequence, status, localOutput, channelIdHigh, channelIdLow, null, contentLength, contentBacking, contentPosition, contentMask); }
public static void publishArrayResponse(int requestContext, int sequence, int status, Pipe<ServerResponseSchema> localOutput, long channelId, byte[] typeBytes, byte[] content) { int channelIdHigh = (int)(channelId>>32); int channelIdLow = (int)channelId; publishArrayResponse(requestContext, sequence, status, localOutput, channelIdHigh, channelIdLow, typeBytes, content); }
private void processRequest(int httpRequestResponseId, Pipe<ServerResponseSchema> output, Pipe<ClientHTTPRequestSchema> toTwitter, long friendUserId, long connectionId, int sequenceID) { long now = System.currentTimeMillis(); if (isThisTheTime(now)) { //do it now, toTwitter then take response and relay it back publishRequest(toTwitter, httpRequestResponseId, friendUserId); } else { //too quickly, send back 420 int contentLength = 1; long seconds = ( (nextTriggerTime-now)+1000 )/1000; if (seconds>127) { //cap out at 127 seconds seconds = 127; } contentBacking[0] = (byte)seconds; int channelIdHigh = (int)(connectionId>>32); int channelIdLow = (int)connectionId; HTTPUtil.publishArrayResponse(ServerCoordinator.END_RESPONSE_MASK | ServerCoordinator.CLOSE_CONNECTION_MASK, sequenceID, 420, output, channelIdHigh, channelIdLow, null, contentLength, contentBacking, contentPosition, contentMask); //clear so the next call will not be blocked activeConnectionId = -1; activeSequenceId = -1; } }
int contentMask = Integer.MAX_VALUE; HTTPUtil.publishArrayResponse(ServerCoordinator.END_RESPONSE_MASK, fieldSequence, 200, output, channelIdHigh, channelIdLow, HTTPContentTypeDefaults.DOT.getBytes(),
private void process(Pipe<HTTPRequestSchema> input, Pipe<ServerResponseSchema> output) { while (Pipe.hasContentToRead(input)) { int msgIdx = Pipe.takeMsgIdx(input); switch(msgIdx) { case HTTPRequestSchema.MSG_RESTREQUEST_300: long fieldChannelId = Pipe.takeLong(input); int fieldSequence = Pipe.takeInt(input); int fieldVerb = Pipe.takeInt(input); DataInputBlobReader<HTTPRequestSchema> data = Pipe.openInputStream(input); int fieldRevision = Pipe.takeInt(input); int fieldRequestContext = Pipe.takeInt(input); HTTPUtil.publishArrayResponse(fieldRequestContext, fieldSequence, 200, output, fieldChannelId, typeBytes, content); Pipe.confirmLowLevelRead(input, Pipe.sizeOf(input, msgIdx)); Pipe.releaseReadLock(input); break; case -1: Pipe.publishEOF(output); break; } PipeReader.releaseReadLock(input); } }
int channelIdLow = (int)activeConnectionId; HTTPUtil.publishArrayResponse(ServerCoordinator.END_RESPONSE_MASK | ServerCoordinator.CLOSE_CONNECTION_MASK, activeSequenceId, statusId, output, channelIdHigh, channelIdLow, null, contentLength, contentBacking, contentPosition, contentMask);