请问什么地方有C#调用腾讯云通信的DEMO啊。

[复制链接]
查看: 245|回复: 0

24

主题

24

帖子

76

积分

注册会员

Rank: 2

积分
76
发表于 2019-2-17 10:21:32 | 显示全部楼层 |阅读模式

          请问什么地方有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)   
---------------------------


         
              
               
            
            

              
         
      
      
      
腾讯云
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

精彩图文



在线客服(工作时间:9:00-22:00)
400-600-6565

内容导航

微信客服

Copyright   ©2015-2019  云服务器社区  Powered by©Discuz!  技术支持:尊托网络     ( 湘ICP备15009499号-1 )