Esempio n. 1
0
    void SendTextMessageSDK()
    {
        var message = new Message
        {
            message_conv_id          = "1234",
            message_conv_type        = TIMConvType.kTIMConv_Group,
            message_cloud_custom_str = "unity local custom data",
            message_elem_array       = new List <Elem> {
                new Elem
                {
                    elem_type         = TIMElemType.kTIMElem_Text,
                    text_elem_content = Input.text
                }
            },
            message_need_read_receipt             = true,
            message_priority                      = (TIMMsgPriority)SelectedPriority.value,
            message_is_excluded_from_unread_count = IsUnread.isOn,
            message_is_online_msg                 = IsOnline.isOn
        };
        StringBuilder messageId = new StringBuilder(128);

        if (SelectedGroup.value > 0)
        {
            print(GroupList[SelectedGroup.value]);
            message.message_conv_id   = GroupList[SelectedGroup.value];
            message.message_conv_type = TIMConvType.kTIMConv_Group;
            TIMResult res = TencentIMSDK.MsgSendMessage(GroupList[SelectedGroup.value], TIMConvType.kTIMConv_Group, message, messageId, Utils.addAsyncStringDataToScreen(GetResult));
            Result.text = Utils.SynchronizeResult(res);
        }
        else if (SelectedFriend.value > 0)
        {
            print(FriendList[SelectedFriend.value]);
            message.message_conv_id   = FriendList[SelectedFriend.value];
            message.message_conv_type = TIMConvType.kTIMConv_C2C;
            TIMResult res = TencentIMSDK.MsgSendMessage(FriendList[SelectedFriend.value], TIMConvType.kTIMConv_C2C, message, messageId, Utils.addAsyncStringDataToScreen(GetResult));
            Result.text = Utils.SynchronizeResult(res);
        }
        print(IsOnline.isOn);
        print(IsUnread.isOn);
    }
Esempio n. 2
0
    public static void MsgSendMessage()
    {
        string  conv_id = touserid;
        Message message = new Message();

        message.message_conv_id   = conv_id;
        message.message_conv_type = TIMConvType.kTIMConv_C2C;
        List <Elem> messageElems = new List <Elem>();
        Elem        textMessage  = new Elem();

        textMessage.elem_type         = TIMElemType.kTIMElem_Text;
        textMessage.text_elem_content = "圣女峰";
        messageElems.Add(textMessage);
        message.message_elem_array       = messageElems;
        message.message_cloud_custom_str = "unity local custom data";
        StringBuilder messageId = new StringBuilder(128);

        TIMResult res = TencentIMSDK.MsgSendMessage(conv_id, TIMConvType.kTIMConv_C2C, message, messageId, addAsyncDataToConsole);

        Utils.Log(((int)res).ToString());
        Utils.Log(messageId.ToString()); // 同步返回消息ID
        addDataToConsole(res);
        addStringDataToConsole(messageId.ToString());
    }