当前位置: 首页>>代码示例>>Java>>正文


Java ChannelBuffer.setBytes方法代码示例

本文整理汇总了Java中org.jboss.netty.buffer.ChannelBuffer.setBytes方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelBuffer.setBytes方法的具体用法?Java ChannelBuffer.setBytes怎么用?Java ChannelBuffer.setBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.netty.buffer.ChannelBuffer的用法示例。


在下文中一共展示了ChannelBuffer.setBytes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onGuestScienceData

import org.jboss.netty.buffer.ChannelBuffer; //导入方法依赖的package包/类
public void onGuestScienceData(Message msg) {
     String apkFullName = "", topic = "";
     // Check to make sure the message contains the full name of the guest science apk
     if (!msg.getData().containsKey("apkFullName")) {
         mLogger.error(LOG_TAG, "Guest science message doesn't contain the full apk name and " +
                 "will not be processed!");
         return;
     }

     apkFullName = msg.getData().getString("apkFullName");

     if (msg.getData().containsKey("topic")) {
         topic = msg.getData().getString("topic");
         if (topic.length() > 32) {
             mLogger.error(LOG_TAG, "The topic string in the guest science message is too " +
                     "big to send to the ground so the message will not be sent. Length must " +
                     " be no more than 32 characters not " + topic.length() + ".");
             return;
         }
     }

     byte[] data = null;
     if (!msg.getData().containsKey("data")) {
         mLogger.error(LOG_TAG, "Guest science message doesn't contain data and will not be " +
                 "processed.");
         return;
     } else {
         data = msg.getData().getByteArray("data");
         if (data.length > 2048) {
             mLogger.error(LOG_TAG, "The data in the guest science message is too big to send " +
                     "to the ground so the message will not be sent. Length of data must be no" +
                     " more than 2048 bytes not " + data.length + ".");
             return;
         }
     }

     GuestScienceData dataMsg = mMessageFactory.newFromType(GuestScienceData._TYPE);
     Header hdr = mMessageFactory.newFromType(Header._TYPE);

     hdr.setStamp(mNodeConfig.getTimeProvider().getCurrentTime());
     dataMsg.setHeader(hdr);

     dataMsg.setApkName(apkFullName);

     if (msg.what == MessageType.STRING.toInt()) {
         dataMsg.setDataType(GuestScienceData.STRING);
     } else if (msg.what == MessageType.JSON.toInt()) {
         dataMsg.setDataType(GuestScienceData.JSON);
     } else if (msg.what == MessageType.BINARY.toInt()) {
         dataMsg.setDataType(GuestScienceData.BINARY);
     } else {
         mLogger.error(LOG_TAG, "Message type in guest science message is unknown so the message " +
                 "will not be sent to the ground.");
         return;
     }

     dataMsg.setTopic(topic);

     ChannelBuffer dataBuff = dataMsg.getData();
     dataBuff.setBytes(0, data);
     dataBuff.setIndex(0, data.length);
     dataMsg.setData(dataBuff);
     mDataPublisher.publish(dataMsg);
}
 
开发者ID:nasa,项目名称:astrobee_android,代码行数:65,代码来源:ManagerNode.java


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