本文整理汇总了Java中com.ociweb.pronghorn.pipe.ChannelReader类的典型用法代码示例。如果您正苦于以下问题:Java ChannelReader类的具体用法?Java ChannelReader怎么用?Java ChannelReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChannelReader类属于com.ociweb.pronghorn.pipe包,在下文中一共展示了ChannelReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitHeaders
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
public void visitHeaders(ChannelReader stream, Appendable target) {
int id = stream.readShort();
while (id > 0) {
try {
target.append(headers[id].writingRoot());
headerConsume(id, stream, target);
target.append("\n");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
id = stream.readShort();
}
}
示例2: copyStructuredTopic
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
public boolean copyStructuredTopic(CharSequence topic,
ChannelReader inputReader,
MessageConsumer consumer,
WaitFor ap) {
DataInputBlobReader<?> reader = (DataInputBlobReader<?>)inputReader;
assert((0 != (initFeatures & DYNAMIC_MESSAGING))) : "CommandChannel must be created with DYNAMIC_MESSAGING flag";
int pos = reader.absolutePosition();
if (consumer.process(reader)) {
if ((null==goPipe || PipeWriter.hasRoomForWrite(goPipe))
&& PipeWriter.tryWriteFragment(messagePubSub, MessagePubSub.MSG_PUBLISH_103) ) {
PipeWriter.writeInt(messagePubSub, MessagePubSub.MSG_PUBLISH_103_FIELD_QOS_5, ap.policy());
PipeWriter.writeUTF8(messagePubSub, MessagePubSub.MSG_PUBLISH_103_FIELD_TOPIC_1, topic);
PubSubWriter pw = (PubSubWriter) Pipe.outputStream(messagePubSub);
DataOutputBlobWriter.openField(pw);
reader.absolutePosition(pos);//restore position as unread
//direct copy from one to the next
reader.readInto(pw, reader.available());
DataOutputBlobWriter.closeHighLevelField(pw, MessagePubSub.MSG_PUBLISH_103_FIELD_PAYLOAD_3);
PipeWriter.publishWrites(messagePubSub);
publishGo(1,builder.pubSubIndex(), this);
return true;
} else {
reader.absolutePosition(pos);//restore position as unread
return false;//needed to consume but no place to go.
}
} else {
return true;
}
}
示例3: readReqesterData
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
public boolean readReqesterData(ChannelReader reader) {
if (Pipe.hasContentToRead(pipe)) {
if (null==headers) {
//custom call
commandChannel.publishHTTPResponse(connectionId, sequenceCode,
statusCode, hasContinuation,
contentType, writable);
} else {
//full headers call
commandChannel.publishHTTPResponse(connectionId, sequenceCode,
hasContinuation, headers, writable);
}
connectionId = -1;
sequenceCode = -1;
return true;
} else {
if (connectionId>=0 && sequenceCode>=0) {
//will not pick up new data, waiting for these to be consumed.
return false;
} else {
//wait for a following call
////example of what the writer does
//writer.writePackedLong(connectionId);
//writer.writePackedLong(sequenceCode);
connectionId = reader.readPackedLong();
sequenceCode = reader.readPackedLong();
return true;
}
}
}
示例4: read
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
@Override
public void read(HTTPHeader header, ChannelReader reader) {
short type = reader.readShort();
if ((type<0) || (type>=httpSpec.contentTypes.length)) {
this.type = HTTPContentTypeDefaults.UNKNOWN;
} else {
this.type = (HTTPContentType)httpSpec.contentTypes[type];
}
}
示例5: restRequest
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
@Override
public boolean restRequest(final HTTPRequestReader request) {
final StringBuilder cookieValue = new StringBuilder();
Headable eat = new Headable() {
@Override
public void read(HTTPHeader header, ChannelReader httpPayloadReader) {
httpPayloadReader.readUTF(cookieValue);
lastCookie = cookieValue.toString();
}
};
request.openHeaderData(HTTPHeaderDefaults.COOKIE.rootBytes(), eat);
Writable consume = new Writable() {
@Override
public void write(ChannelWriter writer) {
template.render(writer, request);
}
};
return cc.publishHTTPResponse(request.getConnectionId(), request.getSequenceCode(), 200, false,
HTTPContentTypeDefaults.JSON, consume);
}
示例6: restRequest
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
@Override
public boolean restRequest(final HTTPRequestReader request) {
final StringBuilder cookieValue = new StringBuilder();
Headable eat = new Headable() {
@Override
public void read(HTTPHeader header, ChannelReader httpPayloadReader) {
httpPayloadReader.readUTF(cookieValue);
lastCookie = cookieValue.toString();
}
};
request.openHeaderData(HTTPHeaderDefaults.COOKIE.rootBytes(),eat);
Writable render = new Writable() {
@Override
public void write(ChannelWriter writer) {
template.render(writer, request);
}
};
return cc.publishHTTPResponse(request.getConnectionId(), request.getSequenceCode(), 200, false,
HTTPContentTypeDefaults.JSON, render );
}
示例7: message
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
@Override
public boolean message(CharSequence topic, ChannelReader payload) {
int value = payload.readInt();
blinkerChannel.setValueAndBlock(IoTApp.LED_PORT, value==1, PAUSE);
return blinkerChannel.publishTopic(TOPIC, w->{
w.writeInt( 1==value ? 0 : 1 );
});
}
示例8: message
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
@Override
public boolean message(CharSequence topic, ChannelReader payload) {
if (topic.equals(topicTank)) { //.toString().equals(topicTank.toString())) {
lastTankTime = payload.readLong();
lastTankDepth = payload.readInt();
lastTankFuel = payload.readUTF();
}
if (topic.equals(topicPump)) {
lastPumpTime = payload.readLong();
lastPumpFuel = payload.readUTF();
lastPumpPrice = payload.readInt();
lastPumpUnits = payload.readInt();
}
if (topic.equals(topicTotal)) {
//now that we have the total the previous running values are no longer valid
lastPumpTime = 0;
lastPumpUnits = 0;
long totalTime = payload.readLong();
lastTotalName = payload.readUTF();
int price = payload.readInt();
lastTotalUnits = payload.readInt();
lastTotalPrice = (price*lastTotalUnits)/100;
}
repaint();
return true;
}
示例9: message
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
@Override
public boolean message(CharSequence topic, ChannelReader payload) {
if (requestedPBM>0) {
if (activeBPM != requestedPBM && ((System.currentTimeMillis()-requestTime) > REQ_UNCHANGED_MS || activeBPM==0) ) {
activeBPM = requestedPBM;
base = System.currentTimeMillis();
beatIdx = 0;
}
long delta = (++beatIdx*60_000)/activeBPM;
long until = base + delta;
tickCommandChannel.digitalPulse(IoTApp.BUZZER_PORT,500_000);
tickCommandChannel.blockUntil(IoTApp.BUZZER_PORT, until);
if (beatIdx==activeBPM) {
beatIdx = 0;
base += 60_000;
}
}
tickCommandChannel.publishTopic(topic,w->{});//request next tick
return true;
}
示例10: writeHeader
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
public <A extends Appendable> A writeHeader(A target, H header, ChannelReader data) {
try {
target.append(header.writingRoot());
header.writeValue(target, this, data);
} catch (Throwable e) {
logger.error("Bad header unable to parse {} ",header);
throw new RuntimeException(e);
}
return target;
}
示例11: decodeDeltaLong
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
public static long decodeDeltaLong(long[] longDictionary, ChannelReader reader, long map, int idx, long bitMask, Boolean isOptional) {
if (isOptional && MOST_FREQUENT_CASE == (map & bitMask)){
bitMask = bitMask << 1;
return (MOST_FREQUENT_CASE == (map&bitMask)) ? (longDictionary[idx] += reader.readPackedLong()) : longDictionary[idx];
} else {
return (MOST_FREQUENT_CASE == (map & bitMask)) ? (longDictionary[idx] += reader.readPackedLong()) : longDictionary[idx];
}
}
示例12: decodeDefaultInt
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
public static int decodeDefaultInt(ChannelReader reader, long map, int[] defaultValues, long bitMask, int idx, Boolean isOptional) {
if (isOptional && MOST_FREQUENT_CASE == (map & bitMask)) {
bitMask = bitMask << 1;
return (MOST_FREQUENT_CASE == (map & bitMask)) ? defaultValues[idx] : reader.readPackedInt();
} else {
return (MOST_FREQUENT_CASE == (map & bitMask)) ? defaultValues[idx] : reader.readPackedInt();
}
}
示例13: decodeDeltaInt
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
public static int decodeDeltaInt(int[] intDictionary, ChannelReader reader, long map, int idx, long bitMask, Boolean isOptional) {
if (isOptional && MOST_FREQUENT_CASE == (map & bitMask)) {
bitMask = bitMask << 1;
return (MOST_FREQUENT_CASE == (map & bitMask)) ? (intDictionary[idx] += reader.readPackedInt()) : intDictionary[idx];
} else {
return (MOST_FREQUENT_CASE == (map & bitMask)) ? (intDictionary[idx] += reader.readPackedInt()) : intDictionary[idx];
}
}
示例14: decodeCopyInt
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
public static int decodeCopyInt(int[] intDictionary, ChannelReader reader, long map, int idx, long bitMask, Boolean isOptional) {
if (isOptional && MOST_FREQUENT_CASE == (map & bitMask)) {
bitMask = bitMask << 1;
return (MOST_FREQUENT_CASE == (map & bitMask)) ? intDictionary[idx] : (intDictionary[idx] = reader.readPackedInt());
} else {
return (MOST_FREQUENT_CASE == (map & bitMask)) ? intDictionary[idx] : (intDictionary[idx] = reader.readPackedInt());
}
}
示例15: decodePresentInt
import com.ociweb.pronghorn.pipe.ChannelReader; //导入依赖的package包/类
public static int decodePresentInt(ChannelReader reader, long map, long bitMask, Boolean isOptional){
if (isOptional && MOST_FREQUENT_CASE == (map & bitMask)) {
bitMask = bitMask << 1;
return (MOST_FREQUENT_CASE == (map & bitMask)) ? reader.readPackedInt() : null;
} else {
return (MOST_FREQUENT_CASE == (map & bitMask)) ? reader.readPackedInt() : null;
}
}