Skip to content

thomasbrook/im-netcore-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

im-netcore-sdk

im for netcore

具体使用方法,可查看单元测试项目 /Test 目录下

[TestMethod]
public void TestStart()
{
    try
    {
        var base64Secret = "";
        if (base64Secret.Length % 4 > 0)
        {
            base64Secret = base64Secret.PadRight(base64Secret.Length + 4 - base64Secret.Length % 4, '=');
        }

        var outpuBytes = Convert.FromBase64String(base64Secret);
        var rawSecret = Encoding.UTF8.GetString(outpuBytes);
        var im = JsonConvert.DeserializeObject<IMModel>(rawSecret);

        var thirdUID = "test-go-tob";
        var aID = "test";

        var result = new Account(im).GetTokenByThirdUID(thirdUID, aID, "test-go", SexEnum.Unknown, "http://xxxxx/app/rank-list/static/img/defaultavatar.cd935fdb.png", "", "", "");
        if (!string.IsNullOrWhiteSpace(result.Item3))
        {
            Debug.WriteLine(result.Item3);
            return;
        }

        Debug.WriteLine($"token:{result.Item1},openID:{result.Item2}");

        var toUID = "1100";
        var objectName = "RC:textMsg";
        var content = "测试单聊";

        var dataPush = new DataPush(im);
        var res = dataPush.PushConverseData(thirdUID, toUID, objectName, content, "", "", "", "", "", "");
        if (!res.Item1)
        {
            Debug.WriteLine($"PushConverseData exeute fail.{res.Item2 ?? ""}");
            return;
        }

        Debug.WriteLine("PushConverseData exeute finish.");

        content = "测试 事件";
        res = dataPush.PushEventData(thirdUID, toUID, objectName, content, "", "", "", "");
        if (!res.Item1)
        {
            Debug.WriteLine($"PushEventData exeute fail. {res.Item2}");
            return;
        }

        Debug.WriteLine("PushEventData exeute finish.");
    }
    catch (Exception ex)
    {
        Debug.WriteLine(ex.Message);
        Debug.WriteLine(ex.StackTrace);
    }
}

About

im for netcore,任职liveme时编写

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%