C# 调用腾讯即时通信 IM
2021-01-29 16:15
标签:nta rgs 登录 textbox 回调 file xxxxxx llb user IM SDK API 概述 https://cloud.tencent.com/document/product/269/33543 C# 调用腾讯即时通信 IM 标签:nta rgs 登录 textbox 回调 file xxxxxx llb user 原文地址:https://www.cnblogs.com/zhangliang2008/p/11847858.html ///
///
///
public void ImInit()
{
int sdk_app_id = 1400000000;
var data = new { sdk_config_log_file_path = AppDomain.CurrentDomain.BaseDirectory, sdk_config_config_file_path = AppDomain.CurrentDomain.BaseDirectory };
TIMInit(sdk_app_id, JsonConvert.SerializeObject(data));
TIMAddRecvNewMsgCallback(TIMRecvNewMsgCallback);
var tLSSig = new TLSSigAPIv2(sdk_app_id, "163250645178b565ffc0b22618d14a88d8a91d86f0e76813313197a5xxxxxxx");
TIMLogin("用户", tLSSig.GenSig("用户"), CommCallback);
}
private delegate int TIMCommCallback(int code, string desc, string json_params);
private int CommCallback(int code, string desc, string json_params)
{
return code;
}
private delegate void delegateTIMRecvNewMsgCallback(string json_msg_array,IntPtr user_data);
private void TIMRecvNewMsgCallback(string json_msg_array, IntPtr user_data) {
var b = Encoding.Default.GetBytes(json_msg_array);
richTextBox1.AppendText(Encoding.UTF8.GetString(b));
}
private void Form1_Load(object sender, EventArgs e)
{
ImInit();
}