• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AsciiBuffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.fusesource.hawtbuf.AsciiBuffer的典型用法代码示例。如果您正苦于以下问题:Java AsciiBuffer类的具体用法?Java AsciiBuffer怎么用?Java AsciiBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AsciiBuffer类属于org.fusesource.hawtbuf包,在下文中一共展示了AsciiBuffer类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: write

import org.fusesource.hawtbuf.AsciiBuffer; //导入依赖的package包/类
public void write(DataOutput out, StompFrame frame) throws IOException {
    write(out, new AsciiBuffer(frame.getCommand()));
    out.writeByte(NEWLINE_BYTE);

    for (Map.Entry<String, String> entry : frame.getProperties().entrySet()) {
        write(out, encodeHeader(entry.getKey()));
        out.writeByte(COLON_BYTE);
        write(out, encodeHeader(entry.getValue()));
        out.writeByte(NEWLINE_BYTE);
    }

    // denotes end of headers with a new line
    out.writeByte(NEWLINE_BYTE);
    write(out, frame.getContent());
    out.writeByte(NULL_BYTE);
    out.writeByte(NEWLINE_BYTE);
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:18,代码来源:StompCodec.java


示例2: onMessage

import org.fusesource.hawtbuf.AsciiBuffer; //导入依赖的package包/类
/** *********************************************************************************************************
 *
 *  Inbound messages
 *
 ** *********************************************************************************************************/
@Override
public void onMessage(String message) {
    if (this.firstMessage) {
        // if the first message the client sends us is a text message (as denoted by this callback method
        // being called), then we will respond with text messages
        binaryTransfers = false;
        firstMessage = false;
    }

    // convert the string message to bytes message.. our codecs just work with bytes
    Buffer buffer = new AsciiBuffer(message);

    // delegate to the callback the deals with bytes
    onMessage(buffer.getData(), buffer.getOffset(), buffer.getLength());

}
 
开发者ID:christian-posta,项目名称:activemq-apollo-java-port,代码行数:22,代码来源:WebSocketTransport.java


示例3: receiveAscii

import org.fusesource.hawtbuf.AsciiBuffer; //导入依赖的package包/类
public AsciiBuffer receiveAscii() {
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    try {

        int c = in.read();
        while (c >= 0) {
            if (c == 0) {
                return buffer.toBuffer().ascii();
            }
            buffer.write(c);
            c = in.read();
        }
    }catch (IOException e) {
        throw new IllegalStateException("Error receiving!", e);
    }

    throw new IllegalStateException("Socket closed, couldn't complete receiving", new EOFException());
}
 
开发者ID:christian-posta,项目名称:activemq-apollo-java-port,代码行数:19,代码来源:StompClient.java


示例4: parse

import org.fusesource.hawtbuf.AsciiBuffer; //导入依赖的package包/类
@Override
public StompFrame parse(ByteBuffer data) throws IOException {

    while (data.hasRemaining()) {
        byte nextByte = data.get();

        // As of STOMP v1.2 lines can end with CRLF or just LF.
        // Any extra LF before start of the frame command are keep alive values.
        if (nextByte == '\r') {
            continue;
        }

        if (nextByte != '\n') {
            try {
                scratch.put(nextByte);
                continue;
            } catch (BufferOverflowException e) {
                throw new IOException("The maximum command length was exceeded");
            }
        }

        // Once we hit the true end of line and have read Command data we can
        // move onto the next stage, header parsing.
        if (scratch.position() != 0) {
            scratch.flip();
            AsciiBuffer command = new Buffer(scratch).trim().ascii();
            LOG.trace("New incoming STOMP frame, command := {}", command);
            StompFrame frame = new StompFrame(command.toString());
            currentParser = initiateHeaderRead(frame);
            return currentParser.parse(data);
        }
    }

    return null;
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:36,代码来源:StompCodec.java


示例5: checkVirtualHostConfigChanges

import org.fusesource.hawtbuf.AsciiBuffer; //导入依赖的package包/类
private void checkVirtualHostConfigChanges(LoggingTracker tracker) {
    // this is the current config (updated config in cases where config has changed)
    Map<AsciiBuffer,VirtualHostDTO> hostConfigById = resolveHostConfigById();

    CollectionSupport.DiffResult<AsciiBuffer> virtualHostConfigDiff = CollectionSupport.diff(virtualHosts.keySet(), hostConfigById.keySet());

    // apply updates to the virtual hosts for configs that have changed
    updateVirtualHosts(tracker, hostConfigById, virtualHostConfigDiff);
}
 
开发者ID:christian-posta,项目名称:activemq-apollo-java-port,代码行数:10,代码来源:Broker.java


示例6: resolveHostConfigById

import org.fusesource.hawtbuf.AsciiBuffer; //导入依赖的package包/类
private Map<AsciiBuffer, VirtualHostDTO> resolveHostConfigById() {
    HashMap<AsciiBuffer, VirtualHostDTO> rc = new HashMap<AsciiBuffer, VirtualHostDTO>();
    for (VirtualHostDTO dto : config.virtual_hosts) {
        rc.put(AsciiBuffer.ascii(dto.id), dto);
    }
    return rc;
}
 
开发者ID:christian-posta,项目名称:activemq-apollo-java-port,代码行数:8,代码来源:Broker.java


示例7: main

import org.fusesource.hawtbuf.AsciiBuffer; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

		String user = env("ACTIVEMQ_USER", "admin");
		String password = env("ACTIVEMQ_PASSWORD", "password");
		String host = env("ACTIVEMQ_HOST", "localhost");
		int port = Integer.parseInt(env("ACTIVEMQ_PORT", "1883"));
		final String destination = arg(args, 0, "/topic/event");

		int messages = 10000;
		int size = 256;

		String DATA = "abcdefghijklmnopqrstuvwxyz";
		String body = "";
		for (int i = 0; i < size; i++) {
			body += DATA.charAt(i % DATA.length());
		}
		Buffer msg = new AsciiBuffer(body);

		MQTT mqtt = new MQTT();
		mqtt.setHost(host, port);
		mqtt.setUserName(user);
		mqtt.setPassword(password);

		FutureConnection connection = mqtt.futureConnection();
		connection.connect().await();

		final LinkedList<Future<Void>> queue = new LinkedList<Future<Void>>();
		UTF8Buffer topic = new UTF8Buffer(destination);
		for (int i = 1; i <= messages; i++) {

			// Send the publish without waiting for it to complete. This allows
			// us
			// to send multiple message without blocking..
			queue.add(connection.publish(topic, msg, QoS.AT_LEAST_ONCE, false));

			// Eventually we start waiting for old publish futures to complete
			// so that we don't create a large in memory buffer of outgoing
			// message.s
			if (queue.size() >= 1000) {
				queue.removeFirst().await();
			}

			if (i % 1000 == 0) {
				System.out.println(String.format("Sent %d messages.", i));
			}
		}

		queue.add(connection.publish(topic, new AsciiBuffer("SHUTDOWN"), QoS.AT_LEAST_ONCE, false));
	   
		while (!queue.isEmpty()) {
			queue.removeFirst().await();
		}

		connection.disconnect().await();

		System.exit(0);
	}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:58,代码来源:Publisher.java


示例8: getNextId

import org.fusesource.hawtbuf.AsciiBuffer; //导入依赖的package包/类
AsciiBuffer getNextId() {
    return connection.nextId();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:StompEndpoint.java


示例9: ExportStreamManager

import org.fusesource.hawtbuf.AsciiBuffer; //导入依赖的package包/类
ExportStreamManager(OutputStream target, int version) throws IOException {
    this.target = target;
    this.version = version;
    stream = new TarOutputStream(new GZIPOutputStream(target));
    store("ver", new AsciiBuffer(""+version));
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:7,代码来源:ExportStreamManager.java


示例10: createBuffer

import org.fusesource.hawtbuf.AsciiBuffer; //导入依赖的package包/类
@Override
protected AsciiBuffer createBuffer(byte[] data) {
    return new AsciiBuffer(data);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:5,代码来源:AsciiBufferCodec.java


示例11: main

import org.fusesource.hawtbuf.AsciiBuffer; //导入依赖的package包/类
public static void main(String []args) throws Exception {

        String user = env("ACTIVEMQ_USER", "admin");
        String password = env("ACTIVEMQ_PASSWORD", "password");
        String host = env("ACTIVEMQ_HOST", "localhost");
        int port = Integer.parseInt(env("ACTIVEMQ_PORT", "1883"));
        final String destination = arg(args, 0, "/topic/event");

        int messages = 10000;
        int size = 256;

        String DATA = "abcdefghijklmnopqrstuvwxyz";
        String body = "";
        for( int i=0; i < size; i ++) {
            body += DATA.charAt(i%DATA.length());
        }
       Buffer msg = new AsciiBuffer(body);

        MQTT mqtt = new MQTT();
        mqtt.setHost(host, port);
        mqtt.setUserName(user);
        mqtt.setPassword(password);

        FutureConnection connection = mqtt.futureConnection();
        connection.connect().await();

        final LinkedList<Future<Void>> queue = new LinkedList<Future<Void>>();
        UTF8Buffer topic = new UTF8Buffer(destination);
        for( int i=1; i <= messages; i ++) {

            // Send the publish without waiting for it to complete. This allows us
            // to send multiple message without blocking..
            queue.add(connection.publish(topic, msg, QoS.AT_LEAST_ONCE, false));

            // Eventually we start waiting for old publish futures to complete
            // so that we don't create a large in memory buffer of outgoing message.s
            if( queue.size() >= 1000 ) {
                queue.removeFirst().await();
            }

            if( i % 1000 == 0 ) {
                System.out.println(String.format("Sent %d messages.", i));
            }
        }

        queue.add(connection.publish(topic, new AsciiBuffer("SHUTDOWN"), QoS.AT_LEAST_ONCE, false));
        while( !queue.isEmpty() ) {
            queue.removeFirst().await();
        }

        connection.disconnect().await();

        System.exit(0);
    }
 
开发者ID:chipster,项目名称:chipster,代码行数:55,代码来源:Publisher.java


示例12: toAsciiBuffer

import org.fusesource.hawtbuf.AsciiBuffer; //导入依赖的package包/类
public static AsciiBuffer toAsciiBuffer(String value) {
    return new AsciiBuffer(value);
}
 
开发者ID:christian-posta,项目名称:activemq-apollo-java-port,代码行数:4,代码来源:BufferConversions.java


示例13: fromAsciiBuffer

import org.fusesource.hawtbuf.AsciiBuffer; //导入依赖的package包/类
public static String fromAsciiBuffer(AsciiBuffer buffer) {
    return buffer.toString();
}
 
开发者ID:christian-posta,项目名称:activemq-apollo-java-port,代码行数:4,代码来源:BufferConversions.java



注:本文中的org.fusesource.hawtbuf.AsciiBuffer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PluginManager类代码示例发布时间:2022-05-22
下一篇:
Java PdfFormField类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap