本文整理了Java中org.vertx.java.core.buffer.Buffer.<init>()
方法的一些代码示例,展示了Buffer.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.<init>()
方法的具体详情如下:
包路径:org.vertx.java.core.buffer.Buffer
类名称:Buffer
方法名:<init>
[英]Create an empty buffer
[中]创建一个空缓冲区
代码示例来源:origin: jboss-fuse/fabric8
public AmqpHeader(){
this(new Buffer(new byte[]{
'A', 'M', 'Q', 'P', 0, 1, 0, 0
}));
}
代码示例来源:origin: org.vert-x/vertx-core
public Buffer action() throws Exception {
byte[] bytes = Files.readAllBytes(target);
Buffer buff = new Buffer(bytes);
return buff;
}
};
代码示例来源:origin: io.fabric8/gateway-core
public static Buffer toBuffer(ByteBuffer buff) {
Buffer self = new Buffer(buff.remaining());
while( buff.hasRemaining() ) {
self.appendByte(buff.get());
}
return self;
}
代码示例来源:origin: io.fabric8.ipaas.apps/fabric8mq
public static Buffer toBuffer(ByteBuffer buff) {
Buffer self = new Buffer(buff.remaining());
while (buff.hasRemaining()) {
self.appendByte(buff.get());
}
return self;
}
代码示例来源:origin: io.vertx/mod-rxvertx
public Buffer call(JsonObject in) {
try {
return new Buffer(in.encode().getBytes(charset));
}
catch (UnsupportedEncodingException e) {
throw new RuntimeException("Unable to encode JSON (charset="+charset+")",e);
}
}
};
代码示例来源:origin: io.vertx/testtools
/**
* Creates a Buffer containing random bytes
* @param length the size of the Buffer to create
* @param avoid if true, the resulting Buffer will not contain avoidByte
* @param avoidByte A byte that is not to be included in the resulting array
* @return a Buffer of random bytes
*/
public static Buffer generateRandomBuffer(int length, boolean avoid, byte avoidByte) {
byte[] line = generateRandomByteArray(length, avoid, avoidByte);
return new Buffer(line);
}
代码示例来源:origin: vert-x/mod-lang-php
/**
* Writes data to the socket as a binary frame.
*/
public WebSocket writeBinaryFrame(Env env, Value data) {
socket.writeBinaryFrame(new org.vertx.java.core.buffer.Buffer(data.toString()));
return this;
}
代码示例来源:origin: io.fabric8.ipaas.apps/fabric8mq
public static Buffer toBuffer(ByteBuffer buff) {
Buffer self = new Buffer(buff.remaining());
while (buff.hasRemaining()) {
self.appendByte(buff.get());
}
return self;
}
代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq
public static Buffer toBuffer(ByteBuffer buff) {
Buffer self = new Buffer(buff.remaining());
while (buff.hasRemaining()) {
self.appendByte(buff.get());
}
return self;
}
代码示例来源:origin: org.vert-x/vertx-core
/**
* Returns a copy of the entire Buffer.
*/
public Buffer copy() {
return new Buffer(buffer.copy());
}
代码示例来源:origin: org.vert-x/vertx-core
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
DefaultNetSocket sock = socketMap.get(ctx.getChannel());
if (sock != null) {
ChannelBuffer cb = (ChannelBuffer) e.getMessage();
sock.handleDataReceived(new Buffer(cb));
}
}
代码示例来源:origin: vert-x/mod-lang-php
@Override
public Value call(Env arg0, Value arg1) {
dataHandler.handle(new Buffer(arg1.toString()));
return env.wrapJava(this);
}
代码示例来源:origin: org.vert-x/vertx-core
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
Channel ch = e.getChannel();
DefaultNetSocket sock = socketMap.get(ch);
if (sock != null) {
ChannelBuffer buff = (ChannelBuffer) e.getMessage();
sock.handleDataReceived(new Buffer(buff.slice()));
}
}
代码示例来源:origin: com.englishtown/vertx-mod-jersey
/**
* {@inheritDoc}
*/
@Override
public void write(byte[] b) throws IOException {
checkState();
response.write(new Buffer(b));
}
代码示例来源:origin: RichardHightower/slumberdb
private void handlePingFromClient(String textData, Object object) {
if (object instanceof ServerWebSocket) {
ServerWebSocket ws = (ServerWebSocket) object;
final InetSocketAddress inetSocketAddress = ws.remoteAddress();
if (debug) logger.debug("GOT PING", textData, " sending pong to ", inetSocketAddress);
ws.write(new Buffer("pong"));
}
}
代码示例来源:origin: org.vert-x/vertx-core
public void fillInRequest(HttpClientRequest req, String hostHeader) throws Exception {
req.headers().put(HttpHeaders.Names.CONNECTION, "Upgrade");
req.headers().put(HttpHeaders.Names.UPGRADE, "WebSocket");
req.headers().put(HttpHeaders.Names.HOST, hostHeader);
req.headers().put(HttpHeaders.Names.SEC_WEBSOCKET_KEY1, this.challenge.getKey1String());
req.headers().put(HttpHeaders.Names.SEC_WEBSOCKET_KEY2, this.challenge.getKey2String());
Buffer buff = new Buffer(6);
buff.appendBytes(challenge.getKey3());
buff.appendByte((byte) '\r');
buff.appendByte((byte) '\n');
req.write(buff);
}
代码示例来源:origin: liveoak-io/liveoak
@Override
public void sendAuthzError(ResourceState errorState, Resource resource, int status) throws Exception {
URI uri = this.destination.resolve(resource.id());
HttpClientRequest request = this.httpClient.put(uri.getPath(), (response) -> {
});
request.setChunked(true);
RequestContext requestContext = new RequestContext.Builder().build();
ByteBuf encoded = codec.encode(requestContext, errorState);
request.write(new Buffer(encoded));
request.end();
}
代码示例来源:origin: com.englishtown/vertx-mod-jersey
/**
* {@inheritDoc}
*/
@Override
public void flush() throws IOException {
checkState();
// Only flush to underlying very.x response if the content-length has been set
if (buffer.length() > 0 && response.headers().contains(HttpHeaders.CONTENT_LENGTH)) {
response.write(buffer);
buffer = new Buffer();
}
}
代码示例来源:origin: org.vert-x/vertx-core
private void deliverMessage(SockJSSocket sock, String address, Message<JsonObject> jsonMessage) {
JsonObject envelope = new JsonObject().putString("address", address).putObject("body", jsonMessage.body);
if (jsonMessage.replyAddress != null) {
envelope.putString("replyAddress", jsonMessage.replyAddress);
}
sock.writeBuffer(new Buffer(envelope.encode()));
}
代码示例来源:origin: liveoak-io/liveoak
@Override
public void resourceUpdated(ResourceResponse resourceResponse) throws Exception {
URI uri = destinationUri(resourceResponse.resource());
HttpClientRequest request = this.httpClient.put(uri.getPath(), (response) -> {
});
request.setChunked(true);
RequestContext requestContext = new RequestContext.Builder().build();
ByteBuf encoded = codec.encode(requestContext, resourceResponse.state());
request.write(new Buffer(encoded));
request.end();
}
内容来源于网络,如有侵权,请联系作者删除!