package com.wecloud.im.sdk.sample;

import java.util.Date;

import cn.hutool.core.date.DateUtil;

import com.wecloud.im.sdk.WecloudIm;
import com.wecloud.im.sdk.WecloudImClientBuilder;
import com.wecloud.im.sdk.model.PrivateChatMessage;
import com.wecloud.im.sdk.model.message.TextMessage;

/**
 * 发布单聊消息
 * @Author luozh
 * @Date 2022年05月06日 01:37:29
 * @Version 1.0
 */
public class PublishPrivateChatMessageSample {

    public static void main(String[] args) {
//        WecloudIm im = new WecloudImClientBuilder().build("http://139.159.136.86:8082",
//                "QizKVHcILRWp6Td2",
//                "287d04828099fb7de871e9dda845fa8b6b2302faf2ab3737");
        WecloudIm im = new WecloudImClientBuilder().build("http://127.0.0.1:8082",
                "QizKVHcILRWp6Td2",
                "287d04828099fb7de871e9dda845fa8b6b2302faf2ab3737");

        String senderId = "1526788710924972032";
        String toUserId = "1529434627821957120";
        String messageType = "-1";

        TextMessage textMessage = new TextMessage();
        textMessage.setText("这是text消息测试: " + DateUtil.formatDateTime(new Date()));

        boolean silent = true;
        PrivateChatMessage privateChatMessage = new PrivateChatMessage();
        privateChatMessage.setFromUserId(senderId);
        privateChatMessage.setToUserIds(toUserId);
        privateChatMessage.setMessageType(messageType);
        privateChatMessage.setContent(textMessage);
        privateChatMessage.setPushContent("");
        privateChatMessage.setIncludeSender(false);
        privateChatMessage.setPersisted(true);
        privateChatMessage.setSilent(silent);
        Boolean result = im.publishPrivateMessage(privateChatMessage);
    }


}
