package com.wdkl.ncs.android.middleware.tcp.channel;

import com.wdkl.ncs.android.middleware.tcp.TcpClient;
import com.wdkl.ncs.android.middleware.tcp.dto.TcpModel;
import com.wdkl.ncs.android.middleware.tcp.enums.TcpAction;
import com.wdkl.ncs.android.middleware.tcp.enums.TcpType;

public class OtherUtil {
    //分机SOS呼叫，不需要传toId
    public static TcpModel SOSCall(Integer fromId){
        TcpModel tcpModel = new TcpModel();
        tcpModel.setType(TcpType.SOS);
        tcpModel.setAction(TcpAction.SOSAction.CALL);
        tcpModel.setFromId(fromId);
        return tcpModel;
    }

    public static TcpModel SOSCancel(Integer fromId, Integer toId){
        TcpModel tcpModel = new TcpModel();
        tcpModel.setType(TcpType.SOS);
        tcpModel.setAction(TcpAction.SOSAction.CANCEL);
        tcpModel.setFromId(fromId);
        tcpModel.setToId(toId);
        return tcpModel;
    }

    public static TcpModel reInforce(Integer fromId){
        TcpModel tcpModel = new TcpModel();
        tcpModel.setType(TcpType.REINFORCE);
        tcpModel.setAction(TcpAction.ReinforceAction.CALL);
        tcpModel.setFromId(fromId);
        return tcpModel;
    }

    //发送sos相关tcp
    public static void sendSosCall(Integer fromId) {
        TcpModel tcpModel = OtherUtil.SOSCall(fromId);
        TcpClient.getInstance().sendMsg(tcpModel.toJson());
    }

    public static void cancelSosCall(Integer fromId, Integer toId) {
        TcpModel tcpModel = OtherUtil.SOSCancel(fromId, toId);
        TcpClient.getInstance().sendMsg(tcpModel.toJson());
    }

    public static void sendReinforce(Integer fromId) {
        TcpModel tcpModel = reInforce(fromId);
        TcpClient.getInstance().sendMsg(tcpModel.toJson());
    }
}
