com.akaxin.proto.core.CoreProto Java Examples
The following examples show how to use
com.akaxin.proto.core.CoreProto.
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: PushClient.java From openzaly with Apache License 2.0 | 6 votes |
public static byte[] syncWrite(String action, byte[] byteData) { try { CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder(); Map<Integer, String> header = new HashMap<Integer, String>(); header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION); packageDataBuilder.putAllHeader(header); packageDataBuilder.setData(ByteString.copyFrom(byteData)); PlatformSSLClient nettyClient = new PlatformSSLClient(); nettyClient.connect(AKAXIN_PUSH_ADDRESS, AKAXIN_PUSH_PORT); Future<IRedisCommandResponse> future = nettyClient.sendRedisCommand(new RedisCommand() .add(CommandConst.PROTOCOL_VERSION).add(action).add(packageDataBuilder.build().toByteArray())); IRedisCommandResponse response = future.get(5, TimeUnit.SECONDS); nettyClient.disconnect(); if (response != null && response.isSuccess()) { return getResponseBytes(response.getRedisCommand()); } logger.debug("write push to platform finish response={}", response); } catch (Exception e) { logger.error("sync send package error ", e); } return null; }
Example #2
Source File: PushClient.java From wind-im with Apache License 2.0 | 6 votes |
public static byte[] syncWrite(String action, byte[] byteData) { try { CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder(); Map<Integer, String> header = new HashMap<Integer, String>(); header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION); packageDataBuilder.putAllHeader(header); packageDataBuilder.setData(ByteString.copyFrom(byteData)); PlatformSSLClient nettyClient = new PlatformSSLClient(); nettyClient.connect(AKAXIN_PUSH_ADDRESS, AKAXIN_PUSH_PORT); Future<IRedisCommandResponse> future = nettyClient.sendRedisCommand(new RedisCommand() .add(CommandConst.PROTOCOL_VERSION).add(action).add(packageDataBuilder.build().toByteArray())); IRedisCommandResponse response = future.get(5, TimeUnit.SECONDS); nettyClient.disconnect(); if (response != null && response.isSuccess()) { return getResponseBytes(response.getRedisCommand()); } logger.debug("write push to platform finish response={}", response); } catch (Exception e) { logger.error("sync send package error ", e); } return null; }
Example #3
Source File: AbstractU2Handler.java From openzaly with Apache License 2.0 | 6 votes |
protected void msgStatusResponse(Command command, String msgId, long msgTime, int statusValue) { if (command == null || StringUtils.isAnyEmpty(command.getDeviceId(), msgId)) { return; } CoreProto.MsgStatus status = CoreProto.MsgStatus.newBuilder().setMsgId(msgId).setMsgStatus(statusValue) .setMsgServerTime(msgTime).build(); ImStcMessageProto.MsgWithPointer statusMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.MSG_STATUS).setStatus(status).build(); ImStcMessageProto.ImStcMessageRequest request = ImStcMessageProto.ImStcMessageRequest.newBuilder() .addList(statusMsg).build(); CoreProto.TransportPackageData data = CoreProto.TransportPackageData.newBuilder() .setData(request.toByteString()).build(); ChannelWriter.writeByDeviceId(command.getDeviceId(), new RedisCommand().add(CommandConst.PROTOCOL_VERSION) .add(CommandConst.IM_MSG_TOCLIENT).add(data.toByteArray())); }
Example #4
Source File: PlatformClient.java From openzaly with Apache License 2.0 | 6 votes |
public static void asyncWrite(String action, byte[] byteData) { try { CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder(); Map<Integer, String> header = new HashMap<Integer, String>(); header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION); packageDataBuilder.putAllHeader(header); packageDataBuilder.setData(ByteString.copyFrom(byteData)); PlatformSSLClient nettyClient = new PlatformSSLClient(); nettyClient.connect(AKAXIN_PLATFROM_HOST, AKAXIN_PLATFROM_PORT); nettyClient.sendRedisCommand(new RedisCommand().add(CommandConst.PROTOCOL_VERSION).add(action) .add(packageDataBuilder.build().toByteArray())); logger.debug("async write push to platform finish "); nettyClient.disconnect(); } catch (Exception e) { logger.error("async send package to platform error", e); } }
Example #5
Source File: PlatformClient.java From openzaly with Apache License 2.0 | 6 votes |
public static byte[] syncWrite(String action, byte[] byteData) { try { CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder(); Map<Integer, String> header = new HashMap<Integer, String>(); header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION); packageDataBuilder.putAllHeader(header); packageDataBuilder.setData(ByteString.copyFrom(byteData)); PlatformSSLClient nettyClient = new PlatformSSLClient(); nettyClient.connect(AKAXIN_PLATFROM_HOST, AKAXIN_PLATFROM_PORT); Future<IRedisCommandResponse> future = nettyClient.sendRedisCommand(new RedisCommand() .add(CommandConst.PROTOCOL_VERSION).add(action).add(packageDataBuilder.build().toByteArray())); IRedisCommandResponse response = future.get(5, TimeUnit.SECONDS); nettyClient.disconnect(); if (response != null && response.isSuccess()) { return getResponseBytes(response.getRedisCommand()); } logger.debug("sync write data to platform with response={}", response); } catch (Exception e) { logger.error("sync send package error ", e); } return null; }
Example #6
Source File: GroupMessageImageSecretHandler.java From openzaly with Apache License 2.0 | 6 votes |
private void msgResponse(Channel channel, Command command, String from, String to, String msgId, long msgTime) { CoreProto.MsgStatus status = CoreProto.MsgStatus.newBuilder().setMsgId(msgId).setMsgServerTime(msgTime) .setMsgStatus(1).build(); ImStcMessageProto.MsgWithPointer statusMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.MSG_STATUS).setStatus(status).build(); ImStcMessageProto.ImStcMessageRequest request = ImStcMessageProto.ImStcMessageRequest.newBuilder() .addList(0, statusMsg).build(); CoreProto.TransportPackageData data = CoreProto.TransportPackageData.newBuilder() .setData(request.toByteString()).build(); channel.writeAndFlush(new RedisCommand().add(CommandConst.PROTOCOL_VERSION).add(CommandConst.IM_MSG_TOCLIENT) .add(data.toByteArray())); }
Example #7
Source File: PlatformClient.java From openzaly with Apache License 2.0 | 6 votes |
public static void asyncWrite(String action, byte[] byteData) { try { CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder(); Map<Integer, String> header = new HashMap<Integer, String>(); header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION); packageDataBuilder.putAllHeader(header); packageDataBuilder.setData(ByteString.copyFrom(byteData)); PlatformSSLClient nettyClient = new PlatformSSLClient(); nettyClient.connect(AKAXIN_PLATFROM_HOST, AKAXIN_PLATFROM_PORT); nettyClient.sendRedisCommand(new RedisCommand().add(CommandConst.PROTOCOL_VERSION).add(action) .add(packageDataBuilder.build().toByteArray())); logger.debug("async write push to platform finish "); nettyClient.disconnect(); } catch (Exception e) { logger.error("async send package to platform error", e); } }
Example #8
Source File: AbstractU2Handler.java From wind-im with Apache License 2.0 | 6 votes |
/** * 通过channel回执消息状态 */ @Deprecated protected void msgStatusResponse(Channel channel, Command command, String from, String to, String msgId, long msgTime) { CoreProto.MsgStatus status = CoreProto.MsgStatus.newBuilder().setMsgId(msgId).setMsgServerTime(msgTime) .setMsgStatus(1).build(); ImStcMessageProto.MsgWithPointer statusMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.MSG_STATUS).setStatus(status).build(); ImStcMessageProto.ImStcMessageRequest request = ImStcMessageProto.ImStcMessageRequest.newBuilder() .addList(statusMsg).build(); CoreProto.TransportPackageData data = CoreProto.TransportPackageData.newBuilder() .setData(request.toByteString()).build(); channel.writeAndFlush(new RedisCommand().add(CommandConst.PROTOCOL_VERSION).add(CommandConst.IM_MSG_TOCLIENT) .add(data.toByteArray())); }
Example #9
Source File: AbstractU2Handler.java From wind-im with Apache License 2.0 | 6 votes |
protected void msgStatusResponse(Command command, String msgId, long msgTime, int statusValue) { if (command == null || StringUtils.isAnyEmpty(command.getDeviceId(), msgId)) { return; } CoreProto.MsgStatus status = CoreProto.MsgStatus.newBuilder().setMsgId(msgId).setMsgStatus(statusValue) .setMsgServerTime(msgTime).build(); ImStcMessageProto.MsgWithPointer statusMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.MSG_STATUS).setStatus(status).build(); ImStcMessageProto.ImStcMessageRequest request = ImStcMessageProto.ImStcMessageRequest.newBuilder() .addList(statusMsg).build(); CoreProto.TransportPackageData data = CoreProto.TransportPackageData.newBuilder() .setData(request.toByteString()).build(); ChannelWriter.writeByDeviceId(command.getDeviceId(), new RedisCommand().add(CommandConst.PROTOCOL_VERSION) .add(CommandConst.IM_MSG_TOCLIENT).add(data.toByteArray())); }
Example #10
Source File: PlatformClient.java From wind-im with Apache License 2.0 | 6 votes |
public static void asyncWrite(String action, byte[] byteData) { try { CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder(); Map<Integer, String> header = new HashMap<Integer, String>(); header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION); packageDataBuilder.putAllHeader(header); packageDataBuilder.setData(ByteString.copyFrom(byteData)); PlatformSSLClient nettyClient = new PlatformSSLClient(); nettyClient.connect(AKAXIN_PLATFROM_HOST, AKAXIN_PLATFROM_PORT); nettyClient.sendRedisCommand(new RedisCommand().add(CommandConst.PROTOCOL_VERSION).add(action) .add(packageDataBuilder.build().toByteArray())); logger.debug("async write push to platform finish "); nettyClient.disconnect(); } catch (Exception e) { logger.error("async send package to platform error", e); } }
Example #11
Source File: AbstractGroupHandler.java From wind-im with Apache License 2.0 | 6 votes |
protected void msgStatusResponse(Command command, String msgId, long msgTime, boolean success) { if (command == null || StringUtils.isEmpty(command.getDeviceId())) { return; } int statusValue = success ? 1 : 0; CoreProto.MsgStatus status = CoreProto.MsgStatus.newBuilder().setMsgId(msgId).setMsgServerTime(msgTime) .setMsgStatus(statusValue).build(); ImStcMessageProto.MsgWithPointer statusMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.MSG_STATUS).setStatus(status).build(); ImStcMessageProto.ImStcMessageRequest request = ImStcMessageProto.ImStcMessageRequest.newBuilder() .addList(statusMsg).build(); CoreProto.TransportPackageData data = CoreProto.TransportPackageData.newBuilder() .setData(request.toByteString()).build(); ChannelWriter.writeByDeviceId(command.getDeviceId(), new RedisCommand().add(CommandConst.PROTOCOL_VERSION) .add(CommandConst.IM_MSG_TOCLIENT).add(data.toByteArray())); }
Example #12
Source File: AbstractU2Handler.java From openzaly with Apache License 2.0 | 6 votes |
/** * 通过channel回执消息状态 */ @Deprecated protected void msgStatusResponse(Channel channel, Command command, String from, String to, String msgId, long msgTime) { CoreProto.MsgStatus status = CoreProto.MsgStatus.newBuilder().setMsgId(msgId).setMsgServerTime(msgTime) .setMsgStatus(1).build(); ImStcMessageProto.MsgWithPointer statusMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.MSG_STATUS).setStatus(status).build(); ImStcMessageProto.ImStcMessageRequest request = ImStcMessageProto.ImStcMessageRequest.newBuilder() .addList(statusMsg).build(); CoreProto.TransportPackageData data = CoreProto.TransportPackageData.newBuilder() .setData(request.toByteString()).build(); channel.writeAndFlush(new RedisCommand().add(CommandConst.PROTOCOL_VERSION).add(CommandConst.IM_MSG_TOCLIENT) .add(data.toByteArray())); }
Example #13
Source File: ChannelWriter.java From openzaly with Apache License 2.0 | 6 votes |
public static void writeAndClose(final Channel channel, CommandResponse response) { CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder(); CoreProto.ErrorInfo errorInfo = CoreProto.ErrorInfo.newBuilder().setCode(response.getErrCode()) .setInfo(String.valueOf(response.getErrInfo())).build(); packageDataBuilder.setErr(errorInfo); Map<Integer, String> header = new HashMap<Integer, String>(); header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION); packageDataBuilder.putAllHeader(header); if (response.getParams() != null) { packageDataBuilder.setData(ByteString.copyFrom(response.getParams())); } channel.writeAndFlush(new RedisCommand().add(response.getVersion()).add(response.getAction()) .add(packageDataBuilder.build().toByteArray())) .addListener(new GenericFutureListener<Future<? super Void>>() { @Override public void operationComplete(Future<? super Void> future) throws Exception { channel.close(); } }); }
Example #14
Source File: ChannelWriter.java From openzaly with Apache License 2.0 | 6 votes |
public static void writeAndClose(final Channel channel, CommandResponse response) { CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder(); CoreProto.ErrorInfo errorInfo = CoreProto.ErrorInfo.newBuilder().setCode(response.getErrCode()) .setInfo(String.valueOf(response.getErrInfo())).build(); packageDataBuilder.setErr(errorInfo); Map<Integer, String> header = new HashMap<Integer, String>(); header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION); packageDataBuilder.putAllHeader(header); if (response.getParams() != null) { packageDataBuilder.setData(ByteString.copyFrom(response.getParams())); } channel.writeAndFlush(new RedisCommand().add(response.getVersion()).add(response.getAction()) .add(packageDataBuilder.build().toByteArray())) .addListener(new GenericFutureListener<Future<? super Void>>() { @Override public void operationComplete(Future<? super Void> future) throws Exception { channel.close(); } }); }
Example #15
Source File: MessageManageService.java From openzaly with Apache License 2.0 | 6 votes |
@Override public boolean sendGroupWebMessage(WebMessageBean bean) { CoreProto.GroupWeb groupWeb = CoreProto.GroupWeb.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSiteUserId()).setSiteGroupId(bean.getSiteGroupId()).setWebCode(bean.getWebCode()) .setHeight(bean.getHeight()).setHrefUrl(bean.getHrefUrl()).setWidth(bean.getWidth()) .setTime(System.currentTimeMillis()).build(); ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.newBuilder() .setType(MsgType.GROUP_WEB).setGroupWeb(groupWeb).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 #16
Source File: ChannelWriter.java From openzaly with Apache License 2.0 | 6 votes |
public static void write(Channel channel, CommandResponse response) { CoreProto.TransportPackageData.Builder packageDataBuilder = CoreProto.TransportPackageData.newBuilder(); CoreProto.ErrorInfo errorInfo = CoreProto.ErrorInfo.newBuilder().setCode(response.getErrCode()) .setInfo(String.valueOf(response.getErrInfo())).build(); packageDataBuilder.setErr(errorInfo); Map<Integer, String> header = new HashMap<Integer, String>(); header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION); packageDataBuilder.putAllHeader(header); if (response.getParams() != null) { packageDataBuilder.setData(ByteString.copyFrom(response.getParams())); } channel.writeAndFlush(new RedisCommand().add(response.getVersion()).add(response.getAction()) .add(packageDataBuilder.build().toByteArray())); }
Example #17
Source File: AbstractGroupHandler.java From openzaly with Apache License 2.0 | 6 votes |
protected void msgStatusResponse(Command command, String msgId, long msgTime, boolean success) { if (command == null || StringUtils.isEmpty(command.getDeviceId())) { return; } int statusValue = success ? 1 : 0; CoreProto.MsgStatus status = CoreProto.MsgStatus.newBuilder().setMsgId(msgId).setMsgServerTime(msgTime) .setMsgStatus(statusValue).build(); ImStcMessageProto.MsgWithPointer statusMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.MSG_STATUS).setStatus(status).build(); ImStcMessageProto.ImStcMessageRequest request = ImStcMessageProto.ImStcMessageRequest.newBuilder() .addList(statusMsg).build(); CoreProto.TransportPackageData data = CoreProto.TransportPackageData.newBuilder() .setData(request.toByteString()).build(); ChannelWriter.writeByDeviceId(command.getDeviceId(), new RedisCommand().add(CommandConst.PROTOCOL_VERSION) .add(CommandConst.IM_MSG_TOCLIENT).add(data.toByteArray())); }
Example #18
Source File: GroupMessageImageSecretHandler.java From openzaly with Apache License 2.0 | 6 votes |
private void msgResponse(Channel channel, Command command, String from, String to, String msgId, long msgTime) { CoreProto.MsgStatus status = CoreProto.MsgStatus.newBuilder().setMsgId(msgId).setMsgServerTime(msgTime) .setMsgStatus(1).build(); ImStcMessageProto.MsgWithPointer statusMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.MSG_STATUS).setStatus(status).build(); ImStcMessageProto.ImStcMessageRequest request = ImStcMessageProto.ImStcMessageRequest.newBuilder() .addList(0, statusMsg).build(); CoreProto.TransportPackageData data = CoreProto.TransportPackageData.newBuilder() .setData(request.toByteString()).build(); channel.writeAndFlush(new RedisCommand().add(CommandConst.PROTOCOL_VERSION).add(CommandConst.IM_MSG_TOCLIENT) .add(data.toByteArray())); }
Example #19
Source File: PlatformClient.java From openzaly with Apache License 2.0 | 6 votes |
private static byte[] getResponseBytes(RedisCommand redisCommand) { try { String version = redisCommand.getParameterByIndex(0); String action = redisCommand.getParameterByIndex(1); byte[] params = redisCommand.getBytesParamByIndex(2); logger.debug("get package bytes from platform {},{},{}", version, action, params); if (CommandConst.ACTION_RES.equals(action)) { CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params); CoreProto.ErrorInfo error = packageData.getErr(); if ("success".equals(error.getCode())) { return packageData.getData().toByteArray(); } } } catch (Exception e) { logger.error("get package bytes eror,redisCommand={}", redisCommand.toString()); } return null; }
Example #20
Source File: AbstractU2Handler.java From openzaly with Apache License 2.0 | 6 votes |
protected void msgStatusResponse(Command command, String msgId, long msgTime, int statusValue) { if (command == null || StringUtils.isAnyEmpty(command.getDeviceId(), msgId)) { return; } CoreProto.MsgStatus status = CoreProto.MsgStatus.newBuilder().setMsgId(msgId).setMsgStatus(statusValue) .setMsgServerTime(msgTime).build(); ImStcMessageProto.MsgWithPointer statusMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.MSG_STATUS).setStatus(status).build(); ImStcMessageProto.ImStcMessageRequest request = ImStcMessageProto.ImStcMessageRequest.newBuilder() .addList(statusMsg).build(); CoreProto.TransportPackageData data = CoreProto.TransportPackageData.newBuilder() .setData(request.toByteString()).build(); ChannelWriter.writeByDeviceId(command.getDeviceId(), new RedisCommand().add(CommandConst.PROTOCOL_VERSION) .add(CommandConst.IM_MSG_TOCLIENT).add(data.toByteArray())); }
Example #21
Source File: PlatformClientHandler.java From openzaly with Apache License 2.0 | 6 votes |
@Override protected void channelRead0(ChannelHandlerContext ctx, RedisCommand redisCmd) throws Exception { String version = redisCmd.getParameterByIndex(0); String action = redisCmd.getParameterByIndex(1); byte[] params = redisCmd.getBytesParamByIndex(2); CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params); CoreProto.ErrorInfo errInfo = packageData.getErr(); Command command = new Command(); command.setHeader(packageData.getHeaderMap()); command.setParams(packageData.getData().toByteArray()); // logger.info("netty client channel handler command={}", command.toString()); PlatformClientHandler.this.nettyClient .handleResponse(new RedisCommandResponse(redisCmd, errInfo.getCode(), errInfo.getInfo())); }
Example #22
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 #23
Source File: MessageManageService.java From wind-im with Apache License 2.0 | 6 votes |
@Override public boolean sendU2WebMessage(WebMessageBean bean) { CoreProto.U2Web u2Web = CoreProto.U2Web.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSiteUserId()).setSiteFriendId(bean.getSiteFriendId()) .setWebCode(bean.getWebCode()).setHeight(bean.getHeight()).setWidth(bean.getWidth()) .setTime(System.currentTimeMillis()).setHrefUrl(bean.getHrefUrl()).build(); ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.newBuilder() .setType(MsgType.U2_WEB).setU2Web(u2Web).build(); Command command = new Command(); command.setSiteUserId(bean.getSiteUserId()); command.setSiteFriendId(bean.getSiteFriendId()); command.setAction(RequestAction.IM_CTS_MESSAGE.getName()); command.setParams(request.toByteArray()); boolean result = imService.execute(command); logger.info("send u2 web message result={} bean={}", result, bean.toString()); return result; }
Example #24
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 #25
Source File: MessageManageService.java From wind-im with Apache License 2.0 | 6 votes |
@Override public boolean sendGroupWebMessage(WebMessageBean bean) { CoreProto.GroupWeb groupWeb = CoreProto.GroupWeb.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSiteUserId()).setSiteGroupId(bean.getSiteGroupId()).setWebCode(bean.getWebCode()) .setHeight(bean.getHeight()).setHrefUrl(bean.getHrefUrl()).setWidth(bean.getWidth()) .setTime(System.currentTimeMillis()).build(); ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.newBuilder() .setType(MsgType.GROUP_WEB).setGroupWeb(groupWeb).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 #26
Source File: MessageManageService.java From openzaly with Apache License 2.0 | 6 votes |
@Override public boolean sendU2WebMessage(WebMessageBean bean) { CoreProto.U2Web u2Web = CoreProto.U2Web.newBuilder().setMsgId(bean.getMsgId()) .setSiteUserId(bean.getSiteUserId()).setSiteFriendId(bean.getSiteFriendId()) .setWebCode(bean.getWebCode()).setHeight(bean.getHeight()).setWidth(bean.getWidth()) .setTime(System.currentTimeMillis()).setHrefUrl(bean.getHrefUrl()).build(); ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.newBuilder() .setType(MsgType.U2_WEB).setU2Web(u2Web).build(); Command command = new Command(); command.setSiteUserId(bean.getSiteUserId()); command.setSiteFriendId(bean.getSiteFriendId()); command.setAction(RequestAction.IM_CTS_MESSAGE.getName()); command.setParams(request.toByteArray()); boolean result = imService.execute(command); logger.info("send u2 web message result={} bean={}", result, bean.toString()); return result; }
Example #27
Source File: ApiRequestHandler.java From openzaly with Apache License 2.0 | 6 votes |
private void tellClientSessionError(final Channel channel) { // response CoreProto.TransportPackageData.Builder packageBuilder = CoreProto.TransportPackageData.newBuilder(); // header Map<Integer, String> header = new HashMap<Integer, String>(); // 站点业务版本(proto版本) header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION); packageBuilder.putAllHeader(header); // errCode CoreProto.ErrorInfo errInfo = CoreProto.ErrorInfo.newBuilder().setCode(ErrorCode2.ERROR_SESSION.getCode()) .setInfo(ErrorCode2.ERROR_SESSION.getInfo()).build(); packageBuilder.setErr(errInfo); // 协议版本 CommandConst.PROTOCOL_VERSION=1.0 String protocolVersion = CommandConst.PROTOCOL_VERSION; String action = CommandConst.ACTION_RES; channel.writeAndFlush( new RedisCommand().add(protocolVersion).add(action).add(packageBuilder.build().toByteArray())) .addListener(new GenericFutureListener<Future<? super Void>>() { public void operationComplete(Future<? super Void> future) throws Exception { channel.close(); } }); }
Example #28
Source File: AbstractGroupHandler.java From openzaly with Apache License 2.0 | 6 votes |
protected void msgStatusResponse(Command command, String msgId, long msgTime, boolean success) { if (command == null || StringUtils.isEmpty(command.getDeviceId())) { return; } int statusValue = success ? 1 : 0; CoreProto.MsgStatus status = CoreProto.MsgStatus.newBuilder().setMsgId(msgId).setMsgServerTime(msgTime) .setMsgStatus(statusValue).build(); ImStcMessageProto.MsgWithPointer statusMsg = ImStcMessageProto.MsgWithPointer.newBuilder() .setType(MsgType.MSG_STATUS).setStatus(status).build(); ImStcMessageProto.ImStcMessageRequest request = ImStcMessageProto.ImStcMessageRequest.newBuilder() .addList(statusMsg).build(); CoreProto.TransportPackageData data = CoreProto.TransportPackageData.newBuilder() .setData(request.toByteString()).build(); ChannelWriter.writeByDeviceId(command.getDeviceId(), new RedisCommand().add(CommandConst.PROTOCOL_VERSION) .add(CommandConst.IM_MSG_TOCLIENT).add(data.toByteArray())); }
Example #29
Source File: ApiRequestHandler.java From wind-im with Apache License 2.0 | 6 votes |
private void tellClientSessionError(final Channel channel) { // response CoreProto.TransportPackageData.Builder packageBuilder = CoreProto.TransportPackageData.newBuilder(); // header Map<Integer, String> header = new HashMap<Integer, String>(); // 站点业务版本(proto版本) header.put(CoreProto.HeaderKey.SITE_SERVER_VERSION_VALUE, CommandConst.SITE_VERSION); packageBuilder.putAllHeader(header); // errCode CoreProto.ErrorInfo errInfo = CoreProto.ErrorInfo.newBuilder().setCode(ErrorCode2.ERROR_SESSION.getCode()) .setInfo(ErrorCode2.ERROR_SESSION.getInfo()).build(); packageBuilder.setErr(errInfo); // 协议版本 CommandConst.PROTOCOL_VERSION=1.0 String protocolVersion = CommandConst.PROTOCOL_VERSION; String action = CommandConst.ACTION_RES; channel.writeAndFlush( new RedisCommand().add(protocolVersion).add(action).add(packageBuilder.build().toByteArray())) .addListener(new GenericFutureListener<Future<? super Void>>() { public void operationComplete(Future<? super Void> future) throws Exception { channel.close(); } }); }
Example #30
Source File: NettyClientHandler.java From openzaly with Apache License 2.0 | 6 votes |
@Override protected void channelRead0(ChannelHandlerContext ctx, RedisCommand redisCmd) throws Exception { String version = redisCmd.getParameterByIndex(0); String action = redisCmd.getParameterByIndex(1); byte[] params = redisCmd.getBytesParamByIndex(2); CoreProto.TransportPackageData packageData = CoreProto.TransportPackageData.parseFrom(params); CoreProto.ErrorInfo errInfo = packageData.getErr(); Command command = new Command(); command.setHeader(packageData.getHeaderMap()); command.setParams(packageData.getData().toByteArray()); // logger.info("netty client channel handler command={}", command.toString()); NettyClientHandler.this.nettyClient .handleResponse(new RedisCommandResponse(redisCmd, errInfo.getCode(), errInfo.getInfo())); }