|
请问什么地方有C#调用腾讯云通信的DEMO啊。
公司要求使用腾迅云的云通信自己做聊天软件。
现在的问题是腾迅云不提供C#的DEMO,发了工单,也投诉过,也加了他们的IM支持技术群。都很明确答复不提供C#的demo.
然后,我在他们的论坛上上面翻到了一点使用的代码,但是使用代码后,直接就整个应用程序崩溃了。不知道什么原因。
http://bbs.qcloud.com/thread-22228-1-1.html
public delegate void CBOnSuccess(IntPtr data);
public delegate void CBOnError(int code, string desc, IntPtr data);
[StructLayout(LayoutKind.**ential)]
public struct TIMCommCB
{
public CBOnSuccess OnSuccess;
public CBOnError OnError;
public IntPtr data;
}
[StructLayout(LayoutKind.**ential)]
public struct TIMUserInfo
{
public string account_type{get;set;}
public string app_id_at_3rd {get;set;}
public string identifier {get;set;}
public string stiny_id { get; set; }
public UInt64 tiny_id { get; set; }
}
[DllImport(@"libtim.dll")]
public extern unsafe static void TIMSetMode(int mode);
[DllImport(@"libtim.dll")]
public extern unsafe static void TIMSetMessageCallBack(char* c);
[DllImport(@"libtim.dll")]
public extern unsafe static int TIMInit();
[DllImport(@"libtim.dll",CallingConvention=CallingConvention.Cdecl)]
extern unsafe static int TIMLogin(int sdk_app_id, ref TIMUserInfo tim_user, string user_sig, ref TIMCommCB callback);
private unsafe void Form1_Load(object sender, EventArgs e)
{
int sdk_app_id = 1104620500;
var result=TIMInit();
TIMUserInfo user = new TIMUserInfo() ;
user.account_type = "107";
user.app_id_at_3rd = "1104620500";
user.identifier = "c9_2";
string user_sig = "123456";
TIMCommCB callback=new TIMCommCB();
callback.OnSuccess += callback_OnSuccess;
callback.OnError += callback_OnError;
var loginresult=TIMLogin(sdk_app_id, ref user, user_sig, ref callback);
}
void callback_OnError(int code, string desc, IntPtr data)
{
throw new NotImplementedException();
}
void callback_OnSuccess(IntPtr data)
{
MessageBox.Show(data.ToString());
}
上面是具体的代码,只要放入VS中执行,就会直接关掉程序。
直接运行exe文件呢,则会提示
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Error!
Program: ...s\ConsoleApp1\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe
Module: ...ource\repos\ConsoleApp1\WindowsFormsApp1\bin\Debug\libtim.dll
File:
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
(Press Retry to debug the application)
---------------------------
中止(A) 重试(R) 忽略(I)
---------------------------
|
|