All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dingtalk.open.app.api.protocol.SystemCommandExecutor Maven / Gradle / Ivy

There is a newer version: 1.3.7
Show newest version
package com.dingtalk.open.app.api.protocol;

import com.alibaba.fastjson2.JSON;
import com.dingtalk.open.app.stream.network.api.Context;
import com.dingtalk.open.app.stream.network.api.logger.InternalLogger;
import com.dingtalk.open.app.stream.network.api.logger.InternalLoggerFactory;
import com.dingtalk.open.app.stream.protocol.system.DisconnectPayload;
import com.dingtalk.open.app.stream.protocol.system.SystemTopic;

/**
 * @author feiyin
 * @date 2023/3/7
 */
public class SystemCommandExecutor implements CommandExecutor {

    private static final InternalLogger LOGGER = InternalLoggerFactory.getLogger(SystemCommandExecutor.class);

    @Override
    public void execute(Context context) {
        if (SystemTopic.PING.equals(context.getRequest().getTopic())) {
            context.replay(JSON.parseObject(context.getRequest().getData()));
            return;
        }

        if (SystemTopic.DISCONNECT.equals(context.getRequest().getTopic())) {
            DisconnectPayload payload = JSON.parseObject(context.getRequest().getData(), DisconnectPayload.class);
            LOGGER.info("[DingTalk] receive connection close info, connection will close later, connectionId={}, reason={}", context.connectionId(), payload.getReason());
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy