Search in sources :

Example 6 with Command

use of com.akaxin.common.command.Command in project openzaly by akaxincom.

the class GroupNotice method groupMsgNotice.

/**
 * 往群组中发送通知消息<eg:王小王加入了群聊天>
 *
 * @param groupId
 *            发送通知的群
 * @param siteUserId
 *            备用字段,兼容官方号推送通知消息,发送方ID
 */
private void groupMsgNotice(String siteUserId, String siteGroupId, String noticeText) {
    CoreProto.GroupMsgNotice groupMsgNotice = CoreProto.GroupMsgNotice.newBuilder().setMsgId(buildGroupMsgId(siteUserId)).setSiteUserId(siteUserId).setSiteGroupId(siteGroupId).setText(ByteString.copyFromUtf8(noticeText)).setTime(System.currentTimeMillis()).build();
    ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.newBuilder().setType(CoreProto.MsgType.GROUP_NOTICE).setGroupMsgNotice(groupMsgNotice).build();
    Command command = new Command();
    command.setAction(RequestAction.IM_CTS_MESSAGE.getName());
    command.setSiteUserId(siteUserId);
    command.setSiteGroupId(siteGroupId);
    command.setParams(request.toByteArray());
    logger.debug("group msg notice command={}", command.toString());
    groupMsgService.execute(command);
}
Also used : CoreProto(com.akaxin.proto.core.CoreProto) Command(com.akaxin.common.command.Command) ImCtsMessageProto(com.akaxin.proto.site.ImCtsMessageProto)

Example 7 with Command

use of com.akaxin.common.command.Command in project openzaly by akaxincom.

the class NettyClientHandler method channelRead0.

@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()));
}
Also used : CoreProto(com.akaxin.proto.core.CoreProto) Command(com.akaxin.common.command.Command) RedisCommand(com.akaxin.common.command.RedisCommand)

Example 8 with Command

use of com.akaxin.common.command.Command in project openzaly by akaxincom.

the class Bootstrap method startHttpServer.

/**
 * 启动Http服务,提供与扩展服务之间的hai(http application interface)接口功能
 *
 * @throws Exception
 */
private static void startHttpServer(String address, int port) throws Exception {
    new HttpServer() {

        @Override
        public void loadExecutor(AbstracteExecutor<Command, CommandResponse> executor) {
            executor.addChain(HttpUriAction.HTTP_ACTION.getUri(), new HttpRequestHandler());
        }
    }.start(address, port);
    logger.info("{} start http server {}:{} ok.", AkxProject.PLN, address, port);
}
Also used : Command(com.akaxin.common.command.Command) HttpRequestHandler(com.akaxin.site.connector.handler.HttpRequestHandler) HttpServer(com.akaxin.site.connector.http.HttpServer) CommandResponse(com.akaxin.common.command.CommandResponse)

Aggregations

Command (com.akaxin.common.command.Command)8 CommandResponse (com.akaxin.common.command.CommandResponse)4 CoreProto (com.akaxin.proto.core.CoreProto)4 RedisCommand (com.akaxin.common.command.RedisCommand)2 ImCtsMessageProto (com.akaxin.proto.site.ImCtsMessageProto)2 InetSocketAddress (java.net.InetSocketAddress)2 ChannelSession (com.akaxin.common.channel.ChannelSession)1 PluginProto (com.akaxin.proto.core.PluginProto)1 ApiRequestHandler (com.akaxin.site.connector.handler.ApiRequestHandler)1 HttpRequestHandler (com.akaxin.site.connector.handler.HttpRequestHandler)1 ImMessageHandler (com.akaxin.site.connector.handler.ImMessageHandler)1 ImSiteAuthHandler (com.akaxin.site.connector.handler.ImSiteAuthHandler)1 HttpServer (com.akaxin.site.connector.http.HttpServer)1 NettyServer (com.akaxin.site.connector.netty.NettyServer)1 ByteBuf (io.netty.buffer.ByteBuf)1 HttpContent (io.netty.handler.codec.http.HttpContent)1 HttpRequest (io.netty.handler.codec.http.HttpRequest)1 LastHttpContent (io.netty.handler.codec.http.LastHttpContent)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1