|
2 | 2 | using System.Collections.Generic;
|
3 | 3 | using System.Runtime.InteropServices;
|
4 | 4 | using System.Text;
|
| 5 | +using AOT; |
5 | 6 |
|
6 | 7 | public class DiscordRpc
|
7 | 8 | {
|
8 |
| - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
9 |
| - public delegate void ReadyCallback(ref DiscordUser connectedUser); |
| 9 | + [MonoPInvokeCallback(typeof(OnReadyInfo))] |
| 10 | + public static void ReadyCallback(ref DiscordUser connectedUser) { } |
| 11 | + public delegate void OnReadyInfo(ref DiscordUser connectedUser); |
10 | 12 |
|
11 |
| - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
12 |
| - public delegate void DisconnectedCallback(int errorCode, string message); |
| 13 | + [MonoPInvokeCallback(typeof(OnDisconnectedInfo))] |
| 14 | + public static void DisconnectedCallback(int errorCode, string message) { } |
| 15 | + public delegate void OnDisconnectedInfo(int errorCode, string message); |
13 | 16 |
|
14 |
| - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
15 |
| - public delegate void ErrorCallback(int errorCode, string message); |
| 17 | + [MonoPInvokeCallback(typeof(OnErrorInfo))] |
| 18 | + public static void ErrorCallback(int errorCode, string message) { } |
| 19 | + public delegate void OnErrorInfo(int errorCode, string message); |
16 | 20 |
|
17 |
| - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
18 |
| - public delegate void JoinCallback(string secret); |
| 21 | + [MonoPInvokeCallback(typeof(OnJoinInfo))] |
| 22 | + public static void JoinCallback(string secret) { } |
| 23 | + public delegate void OnJoinInfo(string secret); |
19 | 24 |
|
20 |
| - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
21 |
| - public delegate void SpectateCallback(string secret); |
| 25 | + [MonoPInvokeCallback(typeof(OnSpectateInfo))] |
| 26 | + public static void SpectateCallback(string secret) { } |
| 27 | + public delegate void OnSpectateInfo(string secret); |
22 | 28 |
|
23 |
| - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
24 |
| - public delegate void RequestCallback(ref DiscordUser request); |
| 29 | + [MonoPInvokeCallback(typeof(OnRequestInfo))] |
| 30 | + public static void RequestCallback(ref DiscordUser request) { } |
| 31 | + public delegate void OnRequestInfo(ref DiscordUser request); |
25 | 32 |
|
26 | 33 | public struct EventHandlers
|
27 | 34 | {
|
28 |
| - public ReadyCallback readyCallback; |
29 |
| - public DisconnectedCallback disconnectedCallback; |
30 |
| - public ErrorCallback errorCallback; |
31 |
| - public JoinCallback joinCallback; |
32 |
| - public SpectateCallback spectateCallback; |
33 |
| - public RequestCallback requestCallback; |
| 35 | + public OnReadyInfo readyCallback; |
| 36 | + public OnDisconnectedInfo disconnectedCallback; |
| 37 | + public OnErrorInfo errorCallback; |
| 38 | + public OnJoinInfo joinCallback; |
| 39 | + public OnSpectateInfo spectateCallback; |
| 40 | + public OnRequestInfo requestCallback; |
34 | 41 | }
|
35 | 42 |
|
36 | 43 | [Serializable, StructLayout(LayoutKind.Sequential)]
|
@@ -160,7 +167,7 @@ private IntPtr StrToPtr(string input)
|
160 | 167 | var buffer = Marshal.AllocHGlobal(convbytecnt + 1);
|
161 | 168 | for (int i = 0; i < convbytecnt + 1; i++)
|
162 | 169 | {
|
163 |
| - Marshal.WriteByte(buffer, i , 0); |
| 170 | + Marshal.WriteByte(buffer, i, 0); |
164 | 171 | }
|
165 | 172 | _buffers.Add(buffer);
|
166 | 173 | Marshal.Copy(Encoding.UTF8.GetBytes(input), 0, buffer, convbytecnt);
|
|
0 commit comments