Java Code Examples for com.akaxin.proto.core.CoreProto#GroupImage
The following examples show how to use
com.akaxin.proto.core.CoreProto#GroupImage .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SyncGroupMessageHandler.java From wind-im with Apache License 2.0 | 4 votes |
private long groupMessageToClient(Channel channel, String userId, List<GroupMessageBean> groupMessageList) { long nextPointer = 0; ImStcMessageProto.ImStcMessageRequest.Builder requestBuilder = ImStcMessageProto.ImStcMessageRequest .newBuilder(); for (GroupMessageBean bean : groupMessageList) { try { nextPointer = NumUtils.getMax(nextPointer, bean.getId()); switch (bean.getMsgType()) { case CoreProto.MsgType.GROUP_TEXT_VALUE: CoreProto.GroupText groupText = CoreProto.GroupText.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSendUserId()).setSiteGroupId(bean.getSiteGroupId()) .setText(ByteString.copyFromUtf8(bean.getContent())).setTime(bean.getMsgTime()).build(); ImStcMessageProto.MsgWithPointer gmsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.GROUP_TEXT).setPointer(bean.getId()).setGroupText(groupText).build(); requestBuilder.addList(gmsg); break; case CoreProto.MsgType.GROUP_SECRET_TEXT_VALUE: // do nothing break; case CoreProto.MsgType.GROUP_IMAGE_VALUE: CoreProto.GroupImage groupImage = CoreProto.GroupImage.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSendUserId()).setSiteGroupId(bean.getSiteGroupId()) .setImageId(bean.getContent()).setTime(bean.getMsgTime()).build(); ImStcMessageProto.MsgWithPointer groupImageMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.GROUP_IMAGE).setPointer(bean.getId()).setGroupImage(groupImage).build(); requestBuilder.addList(groupImageMsg); break; case CoreProto.MsgType.GROUP_SECRET_IMAGE_VALUE: // do nothing break; case CoreProto.MsgType.GROUP_VOICE_VALUE: CoreProto.GroupVoice groupVoice = CoreProto.GroupVoice.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSendUserId()).setSiteGroupId(bean.getSiteGroupId()) .setVoiceId(bean.getContent()).setTime(bean.getMsgTime()).build(); ImStcMessageProto.MsgWithPointer groupVoiceMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.GROUP_VOICE).setPointer(bean.getId()).setGroupVoice(groupVoice).build(); requestBuilder.addList(groupVoiceMsg); break; case CoreProto.MsgType.GROUP_SECRET_VOICE_VALUE: // do nothing break; case CoreProto.MsgType.GROUP_NOTICE_VALUE: CoreProto.GroupMsgNotice groupNotice = CoreProto.GroupMsgNotice.newBuilder() .setMsgId(bean.getMsgId()).setSiteUserId(bean.getSendUserId()) .setSiteGroupId(bean.getSiteGroupId()).setText(ByteString.copyFromUtf8((bean.getContent()))) .setTime(bean.getMsgTime()).build(); ImStcMessageProto.MsgWithPointer groupMsgNotice = ImStcMessageProto.MsgWithPointer.newBuilder() .setPointer(bean.getId()).setType(MsgType.GROUP_NOTICE).setGroupMsgNotice(groupNotice) .build(); requestBuilder.addList(groupMsgNotice); break; case CoreProto.MsgType.GROUP_WEB_VALUE: WebBean webBean = GsonUtils.fromJson(bean.getContent(), WebBean.class); CoreProto.GroupWeb.Builder groupWeb = CoreProto.GroupWeb.newBuilder(); groupWeb.setMsgId(bean.getMsgId()).setSiteUserId(bean.getSendUserId()) .setSiteGroupId(bean.getSiteGroupId()).setWebCode(webBean.getWebCode()) .setHeight(webBean.getHeight()).setWidth(webBean.getWidth()).setTime(bean.getMsgTime()); if (StringUtils.isNotEmpty(webBean.getHrefUrl())) { groupWeb.setHrefUrl(webBean.getHrefUrl()); } ImStcMessageProto.MsgWithPointer groupWebMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setPointer(bean.getId()).setType(MsgType.GROUP_WEB).setGroupWeb(groupWeb).build(); requestBuilder.addList(groupWebMsg); break; case CoreProto.MsgType.GROUP_WEB_NOTICE_VALUE: WebBean webNoticeBean = GsonUtils.fromJson(bean.getContent(), WebBean.class); CoreProto.GroupWebNotice.Builder groupWebNotice = CoreProto.GroupWebNotice.newBuilder(); groupWebNotice.setMsgId(bean.getMsgId()).setSiteUserId(bean.getSendUserId()) .setSiteGroupId(bean.getSiteGroupId()).setWebCode(webNoticeBean.getWebCode()) .setHeight(webNoticeBean.getHeight()).setTime(bean.getMsgTime()); if (StringUtils.isNotEmpty(webNoticeBean.getHrefUrl())) { groupWebNotice.setHrefUrl(webNoticeBean.getHrefUrl()); } ImStcMessageProto.MsgWithPointer groupWebNoticeMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setPointer(bean.getId()).setType(MsgType.GROUP_WEB_NOTICE) .setGroupWebNotice(groupWebNotice).build(); requestBuilder.addList(groupWebNoticeMsg); break; default: break; } } catch (Exception e) { logger.error(StringHelper.format("sync group message error bean={}", bean), e); } } Map<Integer, String> header = new HashMap<Integer, String>(); header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION); ImStcMessageProto.ImStcMessageRequest request = requestBuilder.build(); CoreProto.TransportPackageData datas = CoreProto.TransportPackageData.newBuilder().putAllHeader(header) .setData(ByteString.copyFrom(request.toByteArray())).build(); channel.writeAndFlush(new RedisCommand().add(CommandConst.PROTOCOL_VERSION).add(CommandConst.IM_MSG_TOCLIENT) .add(datas.toByteArray())); return nextPointer; }
Example 2
Source File: SyncGroupMessageHandler.java From openzaly with Apache License 2.0 | 4 votes |
private long groupMessageToClient(Channel channel, String userId, List<GroupMessageBean> groupMessageList) { long nextPointer = 0; ImStcMessageProto.ImStcMessageRequest.Builder requestBuilder = ImStcMessageProto.ImStcMessageRequest .newBuilder(); for (GroupMessageBean bean : groupMessageList) { try { nextPointer = NumUtils.getMax(nextPointer, bean.getId()); switch (bean.getMsgType()) { case CoreProto.MsgType.GROUP_TEXT_VALUE: CoreProto.GroupText groupText = CoreProto.GroupText.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSendUserId()).setSiteGroupId(bean.getSiteGroupId()) .setText(ByteString.copyFromUtf8(bean.getContent())).setTime(bean.getMsgTime()).build(); ImStcMessageProto.MsgWithPointer gmsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.GROUP_TEXT).setPointer(bean.getId()).setGroupText(groupText).build(); requestBuilder.addList(gmsg); break; case CoreProto.MsgType.GROUP_SECRET_TEXT_VALUE: // do nothing break; case CoreProto.MsgType.GROUP_IMAGE_VALUE: CoreProto.GroupImage groupImage = CoreProto.GroupImage.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSendUserId()).setSiteGroupId(bean.getSiteGroupId()) .setImageId(bean.getContent()).setTime(bean.getMsgTime()).build(); ImStcMessageProto.MsgWithPointer groupImageMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.GROUP_IMAGE).setPointer(bean.getId()).setGroupImage(groupImage).build(); requestBuilder.addList(groupImageMsg); break; case CoreProto.MsgType.GROUP_SECRET_IMAGE_VALUE: // do nothing break; case CoreProto.MsgType.GROUP_VOICE_VALUE: CoreProto.GroupVoice groupVoice = CoreProto.GroupVoice.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSendUserId()).setSiteGroupId(bean.getSiteGroupId()) .setVoiceId(bean.getContent()).setTime(bean.getMsgTime()).build(); ImStcMessageProto.MsgWithPointer groupVoiceMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.GROUP_VOICE).setPointer(bean.getId()).setGroupVoice(groupVoice).build(); requestBuilder.addList(groupVoiceMsg); break; case CoreProto.MsgType.GROUP_SECRET_VOICE_VALUE: // do nothing break; case CoreProto.MsgType.GROUP_NOTICE_VALUE: CoreProto.GroupMsgNotice groupNotice = CoreProto.GroupMsgNotice.newBuilder() .setMsgId(bean.getMsgId()).setSiteUserId(bean.getSendUserId()) .setSiteGroupId(bean.getSiteGroupId()).setText(ByteString.copyFromUtf8((bean.getContent()))) .setTime(bean.getMsgTime()).build(); ImStcMessageProto.MsgWithPointer groupMsgNotice = ImStcMessageProto.MsgWithPointer.newBuilder() .setPointer(bean.getId()).setType(MsgType.GROUP_NOTICE).setGroupMsgNotice(groupNotice) .build(); requestBuilder.addList(groupMsgNotice); break; case CoreProto.MsgType.GROUP_WEB_VALUE: WebBean webBean = GsonUtils.fromJson(bean.getContent(), WebBean.class); CoreProto.GroupWeb.Builder groupWeb = CoreProto.GroupWeb.newBuilder(); groupWeb.setMsgId(bean.getMsgId()).setSiteUserId(bean.getSendUserId()) .setSiteGroupId(bean.getSiteGroupId()).setWebCode(webBean.getWebCode()) .setHeight(webBean.getHeight()).setWidth(webBean.getWidth()).setTime(bean.getMsgTime()); if (StringUtils.isNotEmpty(webBean.getHrefUrl())) { groupWeb.setHrefUrl(webBean.getHrefUrl()); } ImStcMessageProto.MsgWithPointer groupWebMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setPointer(bean.getId()).setType(MsgType.GROUP_WEB).setGroupWeb(groupWeb).build(); requestBuilder.addList(groupWebMsg); break; case CoreProto.MsgType.GROUP_WEB_NOTICE_VALUE: WebBean webNoticeBean = GsonUtils.fromJson(bean.getContent(), WebBean.class); CoreProto.GroupWebNotice.Builder groupWebNotice = CoreProto.GroupWebNotice.newBuilder(); groupWebNotice.setMsgId(bean.getMsgId()).setSiteUserId(bean.getSendUserId()) .setSiteGroupId(bean.getSiteGroupId()).setWebCode(webNoticeBean.getWebCode()) .setHeight(webNoticeBean.getHeight()).setTime(bean.getMsgTime()); if (StringUtils.isNotEmpty(webNoticeBean.getHrefUrl())) { groupWebNotice.setHrefUrl(webNoticeBean.getHrefUrl()); } ImStcMessageProto.MsgWithPointer groupWebNoticeMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setPointer(bean.getId()).setType(MsgType.GROUP_WEB_NOTICE) .setGroupWebNotice(groupWebNotice).build(); requestBuilder.addList(groupWebNoticeMsg); break; default: break; } } catch (Exception e) { logger.error(StringHelper.format("sync group message error bean={}", bean), e); } } Map<Integer, String> header = new HashMap<Integer, String>(); header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION); ImStcMessageProto.ImStcMessageRequest request = requestBuilder.build(); CoreProto.TransportPackageData datas = CoreProto.TransportPackageData.newBuilder().putAllHeader(header) .setData(ByteString.copyFrom(request.toByteArray())).build(); channel.writeAndFlush(new RedisCommand().add(CommandConst.PROTOCOL_VERSION).add(CommandConst.IM_MSG_TOCLIENT) .add(datas.toByteArray())); return nextPointer; }
Example 3
Source File: SyncGroupMessageHandler.java From openzaly with Apache License 2.0 | 4 votes |
private long groupMessageToClient(Channel channel, String userId, List<GroupMessageBean> groupMessageList) { long nextPointer = 0; ImStcMessageProto.ImStcMessageRequest.Builder requestBuilder = ImStcMessageProto.ImStcMessageRequest .newBuilder(); for (GroupMessageBean bean : groupMessageList) { try { nextPointer = NumUtils.getMax(nextPointer, bean.getId()); switch (bean.getMsgType()) { case CoreProto.MsgType.GROUP_TEXT_VALUE: CoreProto.GroupText groupText = CoreProto.GroupText.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSendUserId()).setSiteGroupId(bean.getSiteGroupId()) .setText(ByteString.copyFromUtf8(bean.getContent())).setTime(bean.getMsgTime()).build(); ImStcMessageProto.MsgWithPointer gmsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.GROUP_TEXT).setPointer(bean.getId()).setGroupText(groupText).build(); requestBuilder.addList(gmsg); break; case CoreProto.MsgType.GROUP_SECRET_TEXT_VALUE: // do nothing break; case CoreProto.MsgType.GROUP_IMAGE_VALUE: CoreProto.GroupImage groupImage = CoreProto.GroupImage.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSendUserId()).setSiteGroupId(bean.getSiteGroupId()) .setImageId(bean.getContent()).setTime(bean.getMsgTime()).build(); ImStcMessageProto.MsgWithPointer groupImageMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.GROUP_IMAGE).setPointer(bean.getId()).setGroupImage(groupImage).build(); requestBuilder.addList(groupImageMsg); break; case CoreProto.MsgType.GROUP_SECRET_IMAGE_VALUE: // do nothing break; case CoreProto.MsgType.GROUP_VOICE_VALUE: CoreProto.GroupVoice groupVoice = CoreProto.GroupVoice.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSendUserId()).setSiteGroupId(bean.getSiteGroupId()) .setVoiceId(bean.getContent()).setTime(bean.getMsgTime()).build(); ImStcMessageProto.MsgWithPointer groupVoiceMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.GROUP_VOICE).setPointer(bean.getId()).setGroupVoice(groupVoice).build(); requestBuilder.addList(groupVoiceMsg); break; case CoreProto.MsgType.GROUP_SECRET_VOICE_VALUE: // do nothing break; case CoreProto.MsgType.GROUP_NOTICE_VALUE: CoreProto.GroupMsgNotice groupNotice = CoreProto.GroupMsgNotice.newBuilder() .setMsgId(bean.getMsgId()).setSiteUserId(bean.getSendUserId()) .setSiteGroupId(bean.getSiteGroupId()).setText(ByteString.copyFromUtf8((bean.getContent()))) .setTime(bean.getMsgTime()).build(); ImStcMessageProto.MsgWithPointer groupMsgNotice = ImStcMessageProto.MsgWithPointer.newBuilder() .setPointer(bean.getId()).setType(MsgType.GROUP_NOTICE).setGroupMsgNotice(groupNotice) .build(); requestBuilder.addList(groupMsgNotice); break; case CoreProto.MsgType.GROUP_WEB_VALUE: WebBean webBean = GsonUtils.fromJson(bean.getContent(), WebBean.class); CoreProto.GroupWeb.Builder groupWeb = CoreProto.GroupWeb.newBuilder(); groupWeb.setMsgId(bean.getMsgId()).setSiteUserId(bean.getSendUserId()) .setSiteGroupId(bean.getSiteGroupId()).setWebCode(webBean.getWebCode()) .setHeight(webBean.getHeight()).setWidth(webBean.getWidth()).setTime(bean.getMsgTime()); if (StringUtils.isNotEmpty(webBean.getHrefUrl())) { groupWeb.setHrefUrl(webBean.getHrefUrl()); } ImStcMessageProto.MsgWithPointer groupWebMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setPointer(bean.getId()).setType(MsgType.GROUP_WEB).setGroupWeb(groupWeb).build(); requestBuilder.addList(groupWebMsg); break; case CoreProto.MsgType.GROUP_WEB_NOTICE_VALUE: WebBean webNoticeBean = GsonUtils.fromJson(bean.getContent(), WebBean.class); CoreProto.GroupWebNotice.Builder groupWebNotice = CoreProto.GroupWebNotice.newBuilder(); groupWebNotice.setMsgId(bean.getMsgId()).setSiteUserId(bean.getSendUserId()) .setSiteGroupId(bean.getSiteGroupId()).setWebCode(webNoticeBean.getWebCode()) .setHeight(webNoticeBean.getHeight()).setTime(bean.getMsgTime()); if (StringUtils.isNotEmpty(webNoticeBean.getHrefUrl())) { groupWebNotice.setHrefUrl(webNoticeBean.getHrefUrl()); } ImStcMessageProto.MsgWithPointer groupWebNoticeMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setPointer(bean.getId()).setType(MsgType.GROUP_WEB_NOTICE) .setGroupWebNotice(groupWebNotice).build(); requestBuilder.addList(groupWebNoticeMsg); break; default: break; } } catch (Exception e) { logger.error(StringHelper.format("sync group message error bean={}", bean), e); } } Map<Integer, String> header = new HashMap<Integer, String>(); header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION); ImStcMessageProto.ImStcMessageRequest request = requestBuilder.build(); CoreProto.TransportPackageData datas = CoreProto.TransportPackageData.newBuilder().putAllHeader(header) .setData(ByteString.copyFrom(request.toByteArray())).build(); channel.writeAndFlush(new RedisCommand().add(CommandConst.PROTOCOL_VERSION).add(CommandConst.IM_MSG_TOCLIENT) .add(datas.toByteArray())); return nextPointer; }