當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteBufOutputStream.flush方法代碼示例

本文整理匯總了Java中io.netty.buffer.ByteBufOutputStream.flush方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteBufOutputStream.flush方法的具體用法?Java ByteBufOutputStream.flush怎麽用?Java ByteBufOutputStream.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.netty.buffer.ByteBufOutputStream的用法示例。


在下文中一共展示了ByteBufOutputStream.flush方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: encode

import io.netty.buffer.ByteBufOutputStream; //導入方法依賴的package包/類
@Override
protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception {
    KryoContext kryoContext = kryoContextHolder.get();
    Kryo kryo = kryoContext.getKryo();
    Output output = kryoContext.getOut();
    output.clear();
    ByteBufOutputStream bout = new ByteBufOutputStream(out);
    int startIdx = out.writerIndex();
    bout.write(LENGTH_PLACEHOLDER);
    output.setOutputStream(bout);
    output.writeByte(StreamMessageDecoder.KRYO_STREAM_VERSION);
    kryo.writeClassAndObject(output, msg);
    output.flush();
    bout.flush();
    bout.close();
    output.close();
    
    int endIdx = out.writerIndex();

    out.setInt(startIdx, endIdx - startIdx - 4);
}
 
開發者ID:pulsarIO,項目名稱:jetstream,代碼行數:22,代碼來源:KryoObjectEncoder.java

示例2: sendToClient

import io.netty.buffer.ByteBufOutputStream; //導入方法依賴的package包/類
public static void sendToClient(PlayBlockPayload payload, List<EntityPlayer> players) {
    ByteBufOutputStream out = new ByteBufOutputStream(Unpooled.buffer());

    try {
        payload.write(out);
        out.flush();
    } catch (IOException e) {
        PlayBlock.log(Level.WARN, "Failed to build packet to send to the client");
        return;
    }

    FMLProxyPacket packet = new FMLProxyPacket(out.buffer(), PlayBlock.CHANNEL_ID);

    if (players == null) {
        SharedRuntime.networkWrapper.sendToAll(packet);
    } else {
        for (EntityPlayer player : players) {
            if (player instanceof EntityPlayerMP) {
                SharedRuntime.networkWrapper.sendTo(packet, (EntityPlayerMP) player);
            }
        }
    }
}
 
開發者ID:sk89q,項目名稱:playblock,代碼行數:24,代碼來源:PacketHandler.java

示例3: merge

import io.netty.buffer.ByteBufOutputStream; //導入方法依賴的package包/類
public ByteBuf merge(final JsonGenerator jg, final List<TSMeta> metas) {
	merges++;
	final ByteBufOutputStream os = (ByteBufOutputStream)jg.getOutputTarget();
	final ByteBuf buff = os.buffer();
	//System.err.println("MetaBatch:" + metas.size() + ", Merges:" + merges);
	try {
		int cnt = 0;
		for(final TSMeta tsMeta: metas) {
			if(tsMeta==null) continue;
			jg.writeStartObject();				// start of query
			jg.writeStringField("aggregator", aggregator.name().toLowerCase());
			if(rateOptions!=null) {
				jg.writeStringField("rate", "true");  // FIXME
			}
			if(downSampling!=null) {
				jg.writeStringField("downsample", downSampling);
			}
			
			jg.writeArrayFieldStart("tsuids");								
			jg.writeString(tsMeta.getTSUID());
			jg.writeEndArray();					// end of tsuids
			jg.writeEndObject();				// end of query
			cnt++;
		}  // end of TSMetas
		log.info("Wrote {} TSDUID Queries", cnt);
		jg.writeEndArray(); // end of queries array
		jg.writeEndObject(); // end of request
		jg.flush();
		os.flush();
		jg.close();
		os.close();
		log.info("TSDB Request:\n{}", buff.toString(UTF8));
		return buff;
	} catch (Exception ex) {
		throw new RuntimeException(ex);
	}
}
 
開發者ID:nickman,項目名稱:HeliosStreams,代碼行數:38,代碼來源:RequestBuilder.java

示例4: writeMessage

import io.netty.buffer.ByteBufOutputStream; //導入方法依賴的package包/類
@SneakyThrows(IOException.class)
private void writeMessage(AppendBlock block, ByteBuf out) {
    int startIdx = out.writerIndex();
    ByteBufOutputStream bout = new ByteBufOutputStream(out);
    bout.writeInt(block.getType().getCode());
    bout.write(LENGTH_PLACEHOLDER);
    block.writeFields(bout);
    bout.flush();
    bout.close();
    int endIdx = out.writerIndex();
    int fieldsSize = endIdx - startIdx - TYPE_PLUS_LENGTH_SIZE;
    out.setInt(startIdx + TYPE_SIZE, fieldsSize + currentBlockSize);
}
 
開發者ID:pravega,項目名稱:pravega,代碼行數:14,代碼來源:CommandEncoder.java

示例5: toBytes

import io.netty.buffer.ByteBufOutputStream; //導入方法依賴的package包/類
@Override
public void toBytes(ByteBuf buf) {

    try {
        ByteBufOutputStream bbos = new ByteBufOutputStream(buf);
        write(bbos);
        bbos.flush();
        bbos.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
開發者ID:Qmunity,項目名稱:QmunityLib,代碼行數:13,代碼來源:Packet.java

示例6: sendToServer

import io.netty.buffer.ByteBufOutputStream; //導入方法依賴的package包/類
/**
 * Send a payload to the server.
 * 
 * @param payload
 *            the payload
 */
public static void sendToServer(PlayBlockPayload payload) {
    ByteBufOutputStream out = new ByteBufOutputStream(Unpooled.buffer());

    try {
        payload.write(out);
        out.flush();
    } catch (IOException e) {
        PlayBlock.log(Level.WARN, "Failed to send packet to the server");
        return;
    }

    FMLProxyPacket packet = new FMLProxyPacket(out.buffer(), PlayBlock.CHANNEL_ID);
    SharedRuntime.networkWrapper.sendToServer(packet);
}
 
開發者ID:sk89q,項目名稱:playblock,代碼行數:21,代碼來源:PacketHandler.java

示例7: decode

import io.netty.buffer.ByteBufOutputStream; //導入方法依賴的package包/類
protected ResourceState decode(HttpResponse response) throws Exception {
    ByteBuf buffer = Unpooled.buffer();
    ByteBufOutputStream out = new ByteBufOutputStream(buffer);
    response.getEntity().writeTo(out);
    out.flush();
    out.close();
    System.err.println("===================");
    System.err.println(buffer.toString(Charset.defaultCharset()));
    System.err.println("===================");
    return system.codecManager().decode(MediaType.JSON, buffer);
}
 
開發者ID:liveoak-io,項目名稱:liveoak,代碼行數:12,代碼來源:BasicServerTest.java

示例8: decode

import io.netty.buffer.ByteBufOutputStream; //導入方法依賴的package包/類
protected ResourceState decode(HttpResponse response) throws Exception {
    ByteBuf buffer = Unpooled.buffer();
    ByteBufOutputStream out = new ByteBufOutputStream(buffer);
    response.getEntity().writeTo(out);
    out.flush();
    out.close();
    return system.codecManager().decode(MediaType.GIT_APP_JSON, buffer);
}
 
開發者ID:liveoak-io,項目名稱:liveoak,代碼行數:9,代碼來源:GitApplicationsResourceTest.java

示例9: decode

import io.netty.buffer.ByteBufOutputStream; //導入方法依賴的package包/類
protected ResourceState decode(HttpResponse response) throws Exception {
    ByteBuf buffer = Unpooled.buffer();
    ByteBufOutputStream out = new ByteBufOutputStream(buffer);
    response.getEntity().writeTo(out);
    out.flush();
    out.close();
    System.err.println("========= HttpResponse ==========");
    System.err.println(buffer.toString(Charset.defaultCharset()));
    System.err.println("===================");
    return system.codecManager().decode(MediaType.LOCAL_APP_JSON, buffer);
}
 
開發者ID:liveoak-io,項目名稱:liveoak,代碼行數:12,代碼來源:LocalApplicationsResourceTest.java

示例10: decode

import io.netty.buffer.ByteBufOutputStream; //導入方法依賴的package包/類
protected ResourceState decode(HttpResponse response) throws Exception {
    ByteBuf buffer = Unpooled.buffer();
    ByteBufOutputStream out = new ByteBufOutputStream(buffer);
    response.getEntity().writeTo(out);
    out.flush();
    out.close();
    System.err.println("========= HttpResponse ==========");
    System.err.println(buffer.toString(Charset.defaultCharset()));
    System.err.println("===================");
    return system.codecManager().decode(MediaType.JSON, buffer);
}
 
開發者ID:liveoak-io,項目名稱:liveoak,代碼行數:12,代碼來源:AbstractContainerTest.java

示例11: toResourceState

import io.netty.buffer.ByteBufOutputStream; //導入方法依賴的package包/類
protected ResourceState toResourceState(HttpEntity entity, MediaType contentType) throws Exception {
    ByteBuf buffer = Unpooled.buffer();
    ByteBufOutputStream out = new ByteBufOutputStream(buffer);
    entity.writeTo(out);
    out.flush();
    out.close();
    return this.system.codecManager().decode(contentType, buffer);
}
 
開發者ID:liveoak-io,項目名稱:liveoak,代碼行數:9,代碼來源:AbstractHTTPResourceTestCase.java


注:本文中的io.netty.buffer.ByteBufOutputStream.flush方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。