Java Code Examples for com.akaxin.proto.site.ImCtsMessageProto#ImCtsMessageRequest
The following examples show how to use
com.akaxin.proto.site.ImCtsMessageProto#ImCtsMessageRequest .
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: MessageManageService.java From wind-im with Apache License 2.0 | 6 votes |
@Override public boolean sendU2WebNoticeMessage(WebMessageBean bean) { CoreProto.U2WebNotice u2WebNotice = CoreProto.U2WebNotice.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSiteUserId()).setSiteFriendId(bean.getSiteFriendId()) .setWebCode(bean.getWebCode()).setHrefUrl(bean.getHrefUrl()).setTime(System.currentTimeMillis()) .build(); ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.newBuilder() .setType(MsgType.U2_WEB_NOTICE).setU2WebNotice(u2WebNotice).build(); Command command = new Command(); command.setAction(RequestAction.IM_CTS_MESSAGE.getName()); command.setSiteUserId(bean.getSiteUserId()); command.setSiteFriendId(bean.getSiteFriendId()); command.setParams(request.toByteArray()); boolean result = imService.execute(command); logger.info("send u2 web notice message result={} bean={}", result, bean.toString()); return result; }
Example 2
Source File: MessageManageService.java From openzaly with Apache License 2.0 | 6 votes |
@Override public boolean sendGroupWebNoticeMessage(WebMessageBean bean) { CoreProto.GroupWebNotice groupWebNotice = CoreProto.GroupWebNotice.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSiteUserId()).setSiteGroupId(bean.getSiteGroupId()).setWebCode(bean.getWebCode()) .setTime(System.currentTimeMillis()).setHrefUrl(bean.getHrefUrl()).build(); ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.newBuilder() .setType(MsgType.GROUP_WEB_NOTICE).setGroupWebNotice(groupWebNotice).build(); Command command = new Command(); command.setSiteUserId(bean.getSiteUserId()); command.setAction(RequestAction.IM_CTS_MESSAGE.getName()); command.setParams(request.toByteArray()); boolean result = imService.execute(command); logger.info("send group web message result={} bean={}", result, bean.toString()); return result; }
Example 3
Source File: MessageManageService.java From openzaly with Apache License 2.0 | 6 votes |
@Override public boolean sendU2WebNoticeMessage(WebMessageBean bean) { CoreProto.U2WebNotice u2WebNotice = CoreProto.U2WebNotice.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSiteUserId()).setSiteFriendId(bean.getSiteFriendId()) .setWebCode(bean.getWebCode()).setHrefUrl(bean.getHrefUrl()).setTime(System.currentTimeMillis()) .build(); ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.newBuilder() .setType(MsgType.U2_WEB_NOTICE).setU2WebNotice(u2WebNotice).build(); Command command = new Command(); command.setAction(RequestAction.IM_CTS_MESSAGE.getName()); command.setSiteUserId(bean.getSiteUserId()); command.setSiteFriendId(bean.getSiteFriendId()); command.setParams(request.toByteArray()); boolean result = imService.execute(command); logger.info("send u2 web notice message result={} bean={}", result, bean.toString()); return result; }
Example 4
Source File: GroupMessageTextSecretHandler.java From openzaly with Apache License 2.0 | 5 votes |
public Boolean handle(Command command) { ChannelSession channelSession = command.getChannelSession(); try { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); int type = request.getType().getNumber(); if (CoreProto.MsgType.GROUP_SECRET_TEXT_VALUE == type) { String gmsg_id = request.getGroupSecretText().getMsgId(); String group_user_id = request.getGroupSecretText().getSiteUserId(); String group_id = request.getGroupSecretText().getSiteGroupId(); String group_text = request.getGroupSecretText().getText().toStringUtf8(); command.setSiteGroupId(group_id); // command.setField("group_id", group_id); System.out.println( "GroupMsg = id=" + gmsg_id + "," + group_user_id + "," + group_id + "," + group_text + ","); long msgTime = System.currentTimeMillis(); GroupMessageBean gmsgBean = new GroupMessageBean(); gmsgBean.setMsgTime(msgTime); messageDao.saveGroupMessage(gmsgBean); msgResponse(channelSession.getChannel(), command, group_user_id, group_id, gmsg_id, msgTime); return true; } return true; } catch (Exception e) { e.printStackTrace(); } return false; }
Example 5
Source File: GroupMessageTextHandler.java From wind-im with Apache License 2.0 | 5 votes |
public Boolean handle(Command command) { try { int type = command.getMsgType(); if (CoreProto.MsgType.GROUP_TEXT_VALUE == type) { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String deviceId = command.getDeviceId(); String proxySiteUserId = request.getGroupText().getSiteUserId(); String gmsgId = request.getGroupText().getMsgId(); String groupId = request.getGroupText().getSiteGroupId(); String groupText = request.getGroupText().getText().toStringUtf8(); long msgTime = System.currentTimeMillis(); GroupMessageBean gmsgBean = new GroupMessageBean(); gmsgBean.setMsgId(gmsgId); gmsgBean.setSendUserId(siteUserId); gmsgBean.setSendUserId(command.isProxy() ? proxySiteUserId : siteUserId); gmsgBean.setSendDeviceId(deviceId); gmsgBean.setSiteGroupId(groupId); gmsgBean.setContent(groupText); gmsgBean.setMsgType(type); gmsgBean.setMsgTime(msgTime); LogUtils.requestDebugLog(logger, command, gmsgBean.toString()); boolean success = messageDao.saveGroupMessage(gmsgBean); msgStatusResponse(command, gmsgId, msgTime, success); return success; } return true; } catch (Exception e) { LogUtils.requestErrorLog(logger, command, this.getClass(), e); } return false; }
Example 6
Source File: MessageDispatcher.java From openzaly with Apache License 2.0 | 4 votes |
public static boolean dispatch(Command command) { String action = command.getAction(); LogUtils.requestDebugLog(logger, command, ""); if (RequestAction.IM_CTS_MESSAGE.getName().equalsIgnoreCase(action)) { try { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); switch (request.getType().getNumber()) { case CoreProto.MsgType.NOTICE_VALUE: break; case CoreProto.MsgType.TEXT_VALUE: case CoreProto.MsgType.SECRET_TEXT_VALUE: case CoreProto.MsgType.IMAGE_VALUE: case CoreProto.MsgType.SECRET_IMAGE_VALUE: case CoreProto.MsgType.VOICE_VALUE: case CoreProto.MsgType.SECRET_VOICE_VALUE: case CoreProto.MsgType.U2_MAP_VALUE: case CoreProto.MsgType.U2_SECRET_MAP_VALUE: case CoreProto.MsgType.U2_NOTICE_VALUE: case CoreProto.MsgType.U2_WEB_VALUE: case CoreProto.MsgType.U2_WEB_NOTICE_VALUE: return MessageExecutor.getExecutor().execute("im.cts.message.u2", command); case CoreProto.MsgType.GROUP_TEXT_VALUE: case CoreProto.MsgType.GROUP_SECRET_TEXT_VALUE: case CoreProto.MsgType.GROUP_IMAGE_VALUE: case CoreProto.MsgType.GROUP_SECRET_IMAGE_VALUE: case CoreProto.MsgType.GROUP_VOICE_VALUE: case CoreProto.MsgType.GROUP_SECRET_VOICE_VALUE: case CoreProto.MsgType.GROUP_MAP_VALUE: case CoreProto.MsgType.GROUP_SECRET_MAP_VALUE: case CoreProto.MsgType.GROUP_NOTICE_VALUE: case CoreProto.MsgType.GROUP_WEB_VALUE: case CoreProto.MsgType.GROUP_WEB_NOTICE_VALUE: return MessageExecutor.getExecutor().execute("im.cts.message.group", command); } } catch (Exception e) { logger.error(StringHelper.format("client={} siteUserId={} action={} im message dispatch error", command.getClientIp(), command.getSiteUserId(), command.getAction()), e); } } else if (RequestAction.IM_SYNC_MESSAGE.getName().equalsIgnoreCase(action)) { return MessageExecutor.getExecutor().execute(RequestAction.IM_SYNC_MESSAGE.getName(), command); // return true; } else if (RequestAction.IM_SYNC_FINISH.getName().equalsIgnoreCase(action)) { return MessageExecutor.getExecutor().execute(RequestAction.IM_SYNC_FINISH.getName(), command); // return true; } else if (RequestAction.IM_SYNC_MSGSTATUS.getName().equalsIgnoreCase(action)) { return MessageExecutor.getExecutor().execute(RequestAction.IM_SYNC_MSGSTATUS.getName(), command); // return true; } else if (RequestAction.IM_STC_NOTICE.getName().equalsIgnoreCase(action)) { return MessageExecutor.getExecutor().execute(RequestAction.IM_STC_NOTICE.getName(), command); // return true; } logger.error("client={} siteUserId={} action={} im message with error command={}", command.getClientIp(), command.getSiteUserId(), command.getAction(), command.toString()); return false; }
Example 7
Source File: U2MessageImageSecretHandler.java From openzaly with Apache License 2.0 | 4 votes |
public Boolean handle(Command command) { try { int type = command.getMsgType(); if (CoreProto.MsgType.SECRET_IMAGE_VALUE == type) { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String proxySiteUserId = request.getSecretImage().getSiteUserId(); String siteFriendId = request.getSecretImage().getSiteFriendId(); String msgId = request.getSecretImage().getMsgId(); String tsKey = request.getSecretImage().getBase64TsKey(); String toDeviceId = request.getSecretImage().getToDeviceId(); String imageId = request.getSecretImage().getImageId(); U2MessageBean u2Bean = new U2MessageBean(); u2Bean.setMsgId(msgId); u2Bean.setMsgType(type); u2Bean.setSiteUserId(siteFriendId); u2Bean.setSendUserId(command.isProxy() ? proxySiteUserId : siteUserId); u2Bean.setReceiveUserId(siteFriendId); u2Bean.setContent(imageId); u2Bean.setTsKey(tsKey); u2Bean.setDeviceId(toDeviceId); long msgTime = System.currentTimeMillis(); u2Bean.setMsgTime(System.currentTimeMillis()); LogUtils.requestDebugLog(logger, command, u2Bean.toString()); boolean success = messageDao.saveU2Message(u2Bean); msgStatusResponse(command, msgId, msgTime, success); return success; } return true; } catch (Exception e) { LogUtils.requestErrorLog(logger, command, this.getClass(), e); } return false; }
Example 8
Source File: GroupMessageWebHandler.java From openzaly with Apache License 2.0 | 4 votes |
public Boolean handle(Command command) { try { int type = command.getMsgType(); if (CoreProto.MsgType.GROUP_WEB_VALUE == type) { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String deviceId = command.getDeviceId(); String proxySiteUserId = request.getGroupWeb().getSiteUserId(); String gmsgId = request.getGroupWeb().getMsgId(); String groupId = request.getGroupWeb().getSiteGroupId(); String webCode = request.getGroupWeb().getWebCode(); int webWidth = request.getGroupWeb().getWidth(); int webHeight = request.getGroupWeb().getHeight(); String hrefUrl = request.getGroupWeb().getHrefUrl(); long msgTime = System.currentTimeMillis(); WebBean webBean = new WebBean(); webBean.setWebCode(webCode); webBean.setHeight(webHeight); webBean.setWidth(webWidth); webBean.setHrefUrl(hrefUrl); GroupMessageBean gmsgBean = new GroupMessageBean(); gmsgBean.setMsgId(gmsgId); // gmsgBean.setSendUserId(siteUserId); gmsgBean.setSendUserId(command.isProxy() ? proxySiteUserId : siteUserId); gmsgBean.setSendDeviceId(deviceId); gmsgBean.setSiteGroupId(groupId); gmsgBean.setContent(webBean.toString()); gmsgBean.setMsgType(type); gmsgBean.setMsgTime(msgTime); LogUtils.requestDebugLog(logger, command, gmsgBean.toString()); boolean success = messageDao.saveGroupMessage(gmsgBean); msgStatusResponse(command, gmsgId, msgTime, success); return success; } return true; } catch (Exception e) { LogUtils.requestErrorLog(logger, command, this.getClass(), e); } return false; }
Example 9
Source File: U2MessageImageSecretHandler.java From openzaly with Apache License 2.0 | 4 votes |
public Boolean handle(Command command) { try { int type = command.getMsgType(); if (CoreProto.MsgType.SECRET_IMAGE_VALUE == type) { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String proxySiteUserId = request.getSecretImage().getSiteUserId(); String siteFriendId = request.getSecretImage().getSiteFriendId(); String msgId = request.getSecretImage().getMsgId(); String tsKey = request.getSecretImage().getBase64TsKey(); String toDeviceId = request.getSecretImage().getToDeviceId(); String imageId = request.getSecretImage().getImageId(); U2MessageBean u2Bean = new U2MessageBean(); u2Bean.setMsgId(msgId); u2Bean.setMsgType(type); u2Bean.setSiteUserId(siteFriendId); u2Bean.setSendUserId(command.isProxy() ? proxySiteUserId : siteUserId); u2Bean.setReceiveUserId(siteFriendId); u2Bean.setContent(imageId); u2Bean.setTsKey(tsKey); u2Bean.setDeviceId(toDeviceId); long msgTime = System.currentTimeMillis(); u2Bean.setMsgTime(System.currentTimeMillis()); LogUtils.requestDebugLog(logger, command, u2Bean.toString()); boolean success = messageDao.saveU2Message(u2Bean); msgStatusResponse(command, msgId, msgTime, success); return success; } return true; } catch (Exception e) { LogUtils.requestErrorLog(logger, command, this.getClass(), e); } return false; }
Example 10
Source File: GroupDetectionHandler.java From wind-im with Apache License 2.0 | 4 votes |
public Boolean handle(Command command) { try { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); int type = request.getType().getNumber(); command.setMsgType(type); String siteUserId = command.getSiteUserId(); String siteGroupId = null; String gmsgId = null; switch (type) { case CoreProto.MsgType.GROUP_TEXT_VALUE: if (command.isProxy()) { siteUserId = request.getGroupText().getSiteUserId(); } gmsgId = request.getGroupText().getMsgId(); siteGroupId = request.getGroupText().getSiteGroupId(); case CoreProto.MsgType.GROUP_SECRET_TEXT_VALUE: break; case CoreProto.MsgType.GROUP_IMAGE_VALUE: if (command.isProxy()) { siteUserId = request.getGroupImage().getSiteUserId(); } gmsgId = request.getGroupImage().getMsgId(); siteGroupId = request.getGroupImage().getSiteGroupId(); break; case CoreProto.MsgType.GROUP_SECRET_IMAGE_VALUE: break; case CoreProto.MsgType.GROUP_VOICE_VALUE: if (command.isProxy()) { siteUserId = request.getGroupVoice().getSiteUserId(); } gmsgId = request.getGroupVoice().getMsgId(); siteGroupId = request.getGroupVoice().getSiteGroupId(); break; case CoreProto.MsgType.GROUP_SECRET_VOICE_VALUE: break; case CoreProto.MsgType.GROUP_NOTICE_VALUE: if (command.isProxy()) { siteUserId = request.getGroupMsgNotice().getSiteUserId(); } siteGroupId = request.getGroupMsgNotice().getSiteGroupId(); command.setSiteGroupId(siteGroupId); // 系统下发的消息,直接return true; return true; case CoreProto.MsgType.GROUP_WEB_VALUE: if (command.isProxy()) { siteUserId = request.getGroupWeb().getSiteUserId(); } siteGroupId = request.getGroupWeb().getSiteGroupId(); command.setProxySiteUserId(siteUserId); command.setSiteGroupId(siteGroupId); // 系统下发的消息,直接return true; return true; case CoreProto.MsgType.GROUP_WEB_NOTICE_VALUE: if (command.isProxy()) { siteUserId = request.getGroupWebNotice().getSiteUserId(); } siteGroupId = request.getGroupWebNotice().getSiteGroupId(); command.setProxySiteUserId(siteUserId); command.setSiteGroupId(siteGroupId); // 系统下发的消息,直接return true; return true; default: break; } command.setProxySiteUserId(siteUserId); // 群消息设置siteGroupId command.setSiteGroupId(siteGroupId); // check parameters if (StringUtils.isAnyEmpty(siteUserId, siteGroupId)) { return false; } // check is member of group if (check(siteUserId, siteGroupId)) { return true; } else { logger.warn("client={} siteUserId={} is not group={} member", command.getClientIp(), siteUserId, siteGroupId); int statusValue = -2; msgStatusResponse(command, gmsgId, System.currentTimeMillis(), statusValue); } } catch (Exception e) { LogUtils.requestErrorLog(logger, command, GroupDetectionHandler.class, e); } return false; }
Example 11
Source File: GroupMessageWebHandler.java From wind-im with Apache License 2.0 | 4 votes |
public Boolean handle(Command command) { try { int type = command.getMsgType(); if (CoreProto.MsgType.GROUP_WEB_VALUE == type) { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String deviceId = command.getDeviceId(); String proxySiteUserId = request.getGroupWeb().getSiteUserId(); String gmsgId = request.getGroupWeb().getMsgId(); String groupId = request.getGroupWeb().getSiteGroupId(); String webCode = request.getGroupWeb().getWebCode(); int webWidth = request.getGroupWeb().getWidth(); int webHeight = request.getGroupWeb().getHeight(); String hrefUrl = request.getGroupWeb().getHrefUrl(); long msgTime = System.currentTimeMillis(); WebBean webBean = new WebBean(); webBean.setWebCode(webCode); webBean.setHeight(webHeight); webBean.setWidth(webWidth); webBean.setHrefUrl(hrefUrl); GroupMessageBean gmsgBean = new GroupMessageBean(); gmsgBean.setMsgId(gmsgId); // gmsgBean.setSendUserId(siteUserId); gmsgBean.setSendUserId(command.isProxy() ? proxySiteUserId : siteUserId); gmsgBean.setSendDeviceId(deviceId); gmsgBean.setSiteGroupId(groupId); gmsgBean.setContent(webBean.toString()); gmsgBean.setMsgType(type); gmsgBean.setMsgTime(msgTime); LogUtils.requestDebugLog(logger, command, gmsgBean.toString()); boolean success = messageDao.saveGroupMessage(gmsgBean); msgStatusResponse(command, gmsgId, msgTime, success); return success; } return true; } catch (Exception e) { LogUtils.requestErrorLog(logger, command, this.getClass(), e); } return false; }
Example 12
Source File: U2MessageWebHandler.java From openzaly with Apache License 2.0 | 4 votes |
public Boolean handle(Command command) { try { int type = command.getMsgType(); // 获取是否web消息类型 if (CoreProto.MsgType.U2_WEB_VALUE == type) { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String proxySiteUserId = request.getU2Web().getSiteUserId(); String siteFriendId = request.getU2Web().getSiteFriendId(); String msgId = request.getU2Web().getMsgId(); String webCode = request.getU2Web().getWebCode(); int webWidth = request.getU2Web().getWidth(); int webHeight = request.getU2Web().getHeight(); String hrefUrl = request.getU2Web().getHrefUrl(); long msgTime = System.currentTimeMillis(); WebBean webBean = new WebBean(); webBean.setWebCode(webCode); webBean.setHeight(webHeight); webBean.setWidth(webWidth); webBean.setHrefUrl(hrefUrl); U2MessageBean bean = new U2MessageBean(); bean.setMsgId(msgId); bean.setMsgType(type); bean.setSiteUserId(siteFriendId); bean.setSendUserId(command.isProxy() ? proxySiteUserId : siteUserId); bean.setReceiveUserId(siteFriendId); bean.setContent(webBean.toString()); bean.setMsgTime(msgTime); LogUtils.requestDebugLog(logger, command, bean.toString()); boolean success = messageDao.saveU2Message(bean); if (success && command.isProxy()) { U2MessageBean proxyBean = new U2MessageBean(); proxyBean.setMsgId(buildU2MsgId(proxySiteUserId)); proxyBean.setMsgType(type); proxyBean.setSiteUserId(proxySiteUserId); proxyBean.setSendUserId(proxySiteUserId); proxyBean.setReceiveUserId(siteFriendId); // 这里兼容一个客户端的chatSessionId Bug if (hrefUrl.contains("page=plugin_for_u2_chat&site_user_id")) { String oldPar = "plugin_for_u2_chat&site_user_id=" + proxySiteUserId; String newPar = "plugin_for_u2_chat&site_user_id=" + siteFriendId; String hrefUrl2 = hrefUrl.replace(oldPar, newPar); webBean.setHrefUrl(hrefUrl2); } proxyBean.setContent(webBean.toString()); proxyBean.setMsgTime(msgTime); messageDao.saveU2Message(proxyBean); } msgStatusResponse(command, msgId, msgTime, success); return success; } return true; } catch (Exception e) { LogUtils.requestErrorLog(logger, command, this.getClass(), e); } return false; }
Example 13
Source File: UserDetectionHandler.java From wind-im with Apache License 2.0 | 4 votes |
@Override public Boolean handle(Command command) { try { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String siteFriendId = null; String msgId = null; int type = request.getType().getNumber(); command.setMsgType(type); switch (type) { case CoreProto.MsgType.TEXT_VALUE: if (command.isProxy()) { siteUserId = request.getText().getSiteUserId(); } siteFriendId = request.getText().getSiteFriendId(); msgId = request.getText().getMsgId(); break; case CoreProto.MsgType.SECRET_TEXT_VALUE: if (command.isProxy()) { siteUserId = request.getSecretText().getSiteUserId(); } siteFriendId = request.getSecretText().getSiteFriendId(); msgId = request.getSecretText().getMsgId(); break; case CoreProto.MsgType.IMAGE_VALUE: if (command.isProxy()) { siteUserId = request.getImage().getSiteUserId(); } siteFriendId = request.getImage().getSiteFriendId(); msgId = request.getImage().getMsgId(); break; case CoreProto.MsgType.SECRET_IMAGE_VALUE: if (command.isProxy()) { siteUserId = request.getSecretImage().getSiteUserId(); } siteFriendId = request.getSecretImage().getSiteFriendId(); msgId = request.getSecretImage().getMsgId(); break; case CoreProto.MsgType.VOICE_VALUE: if (command.isProxy()) { siteUserId = request.getVoice().getSiteUserId(); } siteFriendId = request.getVoice().getSiteFriendId(); msgId = request.getVoice().getMsgId(); break; case CoreProto.MsgType.SECRET_VOICE_VALUE: if (command.isProxy()) { siteUserId = request.getSecretVoice().getSiteUserId(); } siteFriendId = request.getSecretVoice().getSiteFriendId(); msgId = request.getSecretVoice().getMsgId(); break; case CoreProto.MsgType.U2_NOTICE_VALUE: // 通知消息不需要返回response command.setMsgType(type); return true; case CoreProto.MsgType.U2_WEB_VALUE: if (command.isProxy()) { siteUserId = request.getU2Web().getSiteUserId(); } siteFriendId = request.getU2Web().getSiteFriendId(); command.setProxySiteUserId(siteUserId); command.setSiteFriendId(siteFriendId); return true; case CoreProto.MsgType.U2_WEB_NOTICE_VALUE: if (command.isProxy()) { siteUserId = request.getU2WebNotice().getSiteUserId(); siteFriendId = request.getU2WebNotice().getSiteFriendId(); command.setProxySiteUserId(siteUserId); command.setSiteFriendId(siteFriendId); } return true; default: logger.error("error message type cmd={} request={}", command.toString(), request.toString()); return false; } command.setProxySiteUserId(siteUserId); command.setSiteFriendId(siteFriendId); if (checkUser(siteUserId, siteFriendId, command.isMasterDB())) { return true; } else { logger.warn("users arent friend relation.siteUserId:{},siteFriendId:{}", siteUserId, siteFriendId); int statusValue = -1;// 非好友关系,返回状态值 msgStatusResponse(command, msgId, System.currentTimeMillis(), statusValue); } } catch (Exception e) { LogUtils.requestErrorLog(logger, command, this.getClass(), e); } return false; }
Example 14
Source File: GroupDetectionHandler.java From openzaly with Apache License 2.0 | 4 votes |
public Boolean handle(Command command) { try { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); int type = request.getType().getNumber(); command.setMsgType(type); String siteUserId = command.getSiteUserId(); String siteGroupId = null; String gmsgId = null; switch (type) { case CoreProto.MsgType.GROUP_TEXT_VALUE: if (command.isProxy()) { siteUserId = request.getGroupText().getSiteUserId(); } gmsgId = request.getGroupText().getMsgId(); siteGroupId = request.getGroupText().getSiteGroupId(); case CoreProto.MsgType.GROUP_SECRET_TEXT_VALUE: break; case CoreProto.MsgType.GROUP_IMAGE_VALUE: if (command.isProxy()) { siteUserId = request.getGroupImage().getSiteUserId(); } gmsgId = request.getGroupImage().getMsgId(); siteGroupId = request.getGroupImage().getSiteGroupId(); break; case CoreProto.MsgType.GROUP_SECRET_IMAGE_VALUE: break; case CoreProto.MsgType.GROUP_VOICE_VALUE: if (command.isProxy()) { siteUserId = request.getGroupVoice().getSiteUserId(); } gmsgId = request.getGroupVoice().getMsgId(); siteGroupId = request.getGroupVoice().getSiteGroupId(); break; case CoreProto.MsgType.GROUP_SECRET_VOICE_VALUE: break; case CoreProto.MsgType.GROUP_NOTICE_VALUE: if (command.isProxy()) { siteUserId = request.getGroupMsgNotice().getSiteUserId(); } siteGroupId = request.getGroupMsgNotice().getSiteGroupId(); command.setSiteGroupId(siteGroupId); // 系统下发的消息,直接return true; return true; case CoreProto.MsgType.GROUP_WEB_VALUE: if (command.isProxy()) { siteUserId = request.getGroupWeb().getSiteUserId(); } siteGroupId = request.getGroupWeb().getSiteGroupId(); command.setProxySiteUserId(siteUserId); command.setSiteGroupId(siteGroupId); // 系统下发的消息,直接return true; return true; case CoreProto.MsgType.GROUP_WEB_NOTICE_VALUE: if (command.isProxy()) { siteUserId = request.getGroupWebNotice().getSiteUserId(); } siteGroupId = request.getGroupWebNotice().getSiteGroupId(); command.setProxySiteUserId(siteUserId); command.setSiteGroupId(siteGroupId); // 系统下发的消息,直接return true; return true; default: break; } command.setProxySiteUserId(siteUserId); // 群消息设置siteGroupId command.setSiteGroupId(siteGroupId); // check parameters if (StringUtils.isAnyEmpty(siteUserId, siteGroupId)) { return false; } // check is member of group if (check(siteUserId, siteGroupId)) { return true; } else { logger.warn("client={} siteUserId={} is not group={} member", command.getClientIp(), siteUserId, siteGroupId); int statusValue = -2; msgStatusResponse(command, gmsgId, System.currentTimeMillis(), statusValue); } } catch (Exception e) { LogUtils.requestErrorLog(logger, command, GroupDetectionHandler.class, e); } return false; }
Example 15
Source File: U2MessageVoiceSecretHandler.java From openzaly with Apache License 2.0 | 4 votes |
public Boolean handle(Command command) { try { int type = command.getMsgType(); if (CoreProto.MsgType.SECRET_VOICE_VALUE == type) { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String proxySiteUserId = request.getSecretVoice().getSiteUserId(); String siteFriendId = request.getSecretVoice().getSiteFriendId(); String msgId = request.getSecretVoice().getMsgId(); String tsKey = request.getSecretVoice().getBase64TsKey(); String toDeviceId = request.getSecretVoice().getToDeviceId(); String secretVoiceId = request.getSecretVoice().getVoiceId(); long msgTime = System.currentTimeMillis(); U2MessageBean u2Bean = new U2MessageBean(); u2Bean.setMsgId(msgId); u2Bean.setMsgType(type); u2Bean.setSiteUserId(siteFriendId); u2Bean.setSendUserId(command.isProxy() ? proxySiteUserId : siteUserId); u2Bean.setReceiveUserId(siteFriendId); u2Bean.setContent(secretVoiceId); u2Bean.setTsKey(tsKey); u2Bean.setDeviceId(toDeviceId); u2Bean.setMsgTime(msgTime); LogUtils.requestDebugLog(logger, command, u2Bean.toString()); boolean success = messageDao.saveU2Message(u2Bean); msgStatusResponse(command, msgId, msgTime, success); return success; } return true; } catch (Exception e) { logger.error("U2 Message Secret Voice error!", e); } return false; }
Example 16
Source File: U2MessageTextHandler.java From wind-im with Apache License 2.0 | 4 votes |
public Boolean handle(Command command) { try { int type = command.getMsgType(); if (CoreProto.MsgType.TEXT_VALUE == type) { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String proxySiteUserId = request.getText().getSiteUserId(); String siteFriendId = request.getText().getSiteFriendId(); String msgId = request.getText().getMsgId(); ByteString byteStr = request.getText().getText(); String msgText = byteStr.toString(Charset.forName("UTF-8")); command.setSiteFriendId(siteFriendId); long msgTime = System.currentTimeMillis(); U2MessageBean u2Bean = new U2MessageBean(); u2Bean.setMsgId(msgId); u2Bean.setMsgType(type); u2Bean.setSiteUserId(siteFriendId); u2Bean.setSendUserId(command.isProxy() ? proxySiteUserId : siteUserId); u2Bean.setReceiveUserId(siteFriendId); u2Bean.setContent(msgText); u2Bean.setMsgTime(msgTime); LogUtils.requestDebugLog(logger, command, u2Bean.toString()); boolean success = messageDao.saveU2Message(u2Bean); if (success && command.isProxy()) { U2MessageBean proxyBean = new U2MessageBean(); proxyBean.setMsgId(buildU2MsgId(proxySiteUserId)); proxyBean.setMsgType(type); proxyBean.setSiteUserId(proxySiteUserId); proxyBean.setSendUserId(proxySiteUserId); proxyBean.setReceiveUserId(siteFriendId); proxyBean.setContent(msgText); proxyBean.setMsgTime(msgTime); messageDao.saveU2Message(proxyBean); } msgStatusResponse(command, msgId, msgTime, success); return success; } return true; } catch (Exception e) { LogUtils.requestErrorLog(logger, command, this.getClass(), e); } return false; }
Example 17
Source File: U2MessageTextHandler.java From openzaly with Apache License 2.0 | 4 votes |
public Boolean handle(Command command) { try { int type = command.getMsgType(); if (CoreProto.MsgType.TEXT_VALUE == type) { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String proxySiteUserId = request.getText().getSiteUserId(); String siteFriendId = request.getText().getSiteFriendId(); String msgId = request.getText().getMsgId(); ByteString byteStr = request.getText().getText(); String msgText = byteStr.toString(Charset.forName("UTF-8")); command.setSiteFriendId(siteFriendId); long msgTime = System.currentTimeMillis(); U2MessageBean u2Bean = new U2MessageBean(); u2Bean.setMsgId(msgId); u2Bean.setMsgType(type); u2Bean.setSiteUserId(siteFriendId); u2Bean.setSendUserId(command.isProxy() ? proxySiteUserId : siteUserId); u2Bean.setReceiveUserId(siteFriendId); u2Bean.setContent(msgText); u2Bean.setMsgTime(msgTime); LogUtils.requestDebugLog(logger, command, u2Bean.toString()); boolean success = messageDao.saveU2Message(u2Bean); if (success && command.isProxy()) { U2MessageBean proxyBean = new U2MessageBean(); proxyBean.setMsgId(buildU2MsgId(proxySiteUserId)); proxyBean.setMsgType(type); proxyBean.setSiteUserId(proxySiteUserId); proxyBean.setSendUserId(proxySiteUserId); proxyBean.setReceiveUserId(siteFriendId); proxyBean.setContent(msgText); proxyBean.setMsgTime(msgTime); messageDao.saveU2Message(proxyBean); } msgStatusResponse(command, msgId, msgTime, success); return success; } return true; } catch (Exception e) { LogUtils.requestErrorLog(logger, command, this.getClass(), e); } return false; }
Example 18
Source File: U2MessageTextSecretHandler.java From openzaly with Apache License 2.0 | 4 votes |
public Boolean handle(Command command) { try { int type = command.getMsgType(); if (CoreProto.MsgType.SECRET_TEXT_VALUE == type) { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String proxySiteUserId = request.getSecretText().getSiteUserId(); String siteFriendId = request.getSecretText().getSiteFriendId(); String msgId = request.getSecretText().getMsgId(); String tsKey = request.getSecretText().getBase64TsKey(); String toDeviceId = request.getSecretText().getToDeviceId(); ByteString textBytes = request.getSecretText().getText(); String msgText = Base64.getEncoder().encodeToString(textBytes.toByteArray()); long msgTime = System.currentTimeMillis(); U2MessageBean u2Bean = new U2MessageBean(); u2Bean.setMsgId(msgId); u2Bean.setMsgType(type); u2Bean.setSiteUserId(siteFriendId); u2Bean.setSendUserId(command.isProxy() ? proxySiteUserId : siteUserId); u2Bean.setReceiveUserId(siteFriendId); u2Bean.setContent(msgText); u2Bean.setTsKey(tsKey); u2Bean.setDeviceId(toDeviceId); u2Bean.setMsgTime(msgTime); LogUtils.requestDebugLog(logger, command, u2Bean.toString()); boolean success = messageDao.saveU2Message(u2Bean); msgStatusResponse(command, msgId, msgTime, success); return success; } return true; } catch (Exception e) { LogUtils.requestErrorLog(logger, command, this.getClass(), e); } return false; }
Example 19
Source File: U2MessageTextSecretHandler.java From openzaly with Apache License 2.0 | 4 votes |
public Boolean handle(Command command) { try { int type = command.getMsgType(); if (CoreProto.MsgType.SECRET_TEXT_VALUE == type) { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String proxySiteUserId = request.getSecretText().getSiteUserId(); String siteFriendId = request.getSecretText().getSiteFriendId(); String msgId = request.getSecretText().getMsgId(); String tsKey = request.getSecretText().getBase64TsKey(); String toDeviceId = request.getSecretText().getToDeviceId(); ByteString textBytes = request.getSecretText().getText(); String msgText = Base64.getEncoder().encodeToString(textBytes.toByteArray()); long msgTime = System.currentTimeMillis(); U2MessageBean u2Bean = new U2MessageBean(); u2Bean.setMsgId(msgId); u2Bean.setMsgType(type); u2Bean.setSiteUserId(siteFriendId); u2Bean.setSendUserId(command.isProxy() ? proxySiteUserId : siteUserId); u2Bean.setReceiveUserId(siteFriendId); u2Bean.setContent(msgText); u2Bean.setTsKey(tsKey); u2Bean.setDeviceId(toDeviceId); u2Bean.setMsgTime(msgTime); LogUtils.requestDebugLog(logger, command, u2Bean.toString()); boolean success = messageDao.saveU2Message(u2Bean); msgStatusResponse(command, msgId, msgTime, success); return success; } return true; } catch (Exception e) { LogUtils.requestErrorLog(logger, command, this.getClass(), e); } return false; }
Example 20
Source File: MessageDispatcher.java From wind-im with Apache License 2.0 | 4 votes |
public static boolean dispatch(Command command) { String action = command.getAction(); LogUtils.requestDebugLog(logger, command, ""); if (RequestAction.IM_CTS_MESSAGE.getName().equalsIgnoreCase(action)) { try { ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest .parseFrom(command.getParams()); switch (request.getType().getNumber()) { case CoreProto.MsgType.NOTICE_VALUE: break; case CoreProto.MsgType.TEXT_VALUE: case CoreProto.MsgType.SECRET_TEXT_VALUE: case CoreProto.MsgType.IMAGE_VALUE: case CoreProto.MsgType.SECRET_IMAGE_VALUE: case CoreProto.MsgType.VOICE_VALUE: case CoreProto.MsgType.SECRET_VOICE_VALUE: case CoreProto.MsgType.U2_MAP_VALUE: case CoreProto.MsgType.U2_SECRET_MAP_VALUE: case CoreProto.MsgType.U2_NOTICE_VALUE: case CoreProto.MsgType.U2_WEB_VALUE: case CoreProto.MsgType.U2_WEB_NOTICE_VALUE: return MessageExecutor.getExecutor().execute("im.cts.message.u2", command); case CoreProto.MsgType.GROUP_TEXT_VALUE: case CoreProto.MsgType.GROUP_SECRET_TEXT_VALUE: case CoreProto.MsgType.GROUP_IMAGE_VALUE: case CoreProto.MsgType.GROUP_SECRET_IMAGE_VALUE: case CoreProto.MsgType.GROUP_VOICE_VALUE: case CoreProto.MsgType.GROUP_SECRET_VOICE_VALUE: case CoreProto.MsgType.GROUP_MAP_VALUE: case CoreProto.MsgType.GROUP_SECRET_MAP_VALUE: case CoreProto.MsgType.GROUP_NOTICE_VALUE: case CoreProto.MsgType.GROUP_WEB_VALUE: case CoreProto.MsgType.GROUP_WEB_NOTICE_VALUE: return MessageExecutor.getExecutor().execute("im.cts.message.group", command); } } catch (Exception e) { logger.error(StringHelper.format("client={} siteUserId={} action={} im message dispatch error", command.getClientIp(), command.getSiteUserId(), command.getAction()), e); } } else if (RequestAction.IM_SYNC_MESSAGE.getName().equalsIgnoreCase(action)) { return MessageExecutor.getExecutor().execute(RequestAction.IM_SYNC_MESSAGE.getName(), command); // return true; } else if (RequestAction.IM_SYNC_FINISH.getName().equalsIgnoreCase(action)) { return MessageExecutor.getExecutor().execute(RequestAction.IM_SYNC_FINISH.getName(), command); // return true; } else if (RequestAction.IM_SYNC_MSGSTATUS.getName().equalsIgnoreCase(action)) { return MessageExecutor.getExecutor().execute(RequestAction.IM_SYNC_MSGSTATUS.getName(), command); // return true; } else if (RequestAction.IM_STC_NOTICE.getName().equalsIgnoreCase(action)) { return MessageExecutor.getExecutor().execute(RequestAction.IM_STC_NOTICE.getName(), command); // return true; } logger.error("client={} siteUserId={} action={} im message with error command={}", command.getClientIp(), command.getSiteUserId(), command.getAction(), command.toString()); return false; }