Skip to content

Commit 3d183ea

Browse files
authored
Merge pull request #169 from luckyyuqiang/new
Replace custom MonoPInvokeCallback with AOT attribute.
2 parents 68b4a3b + efc1cf7 commit 3d183ea

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

AgoraChatSDK/AgoraChat/Helper/LogPrinter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class LogPrinter
1111
public static void Log(object message)
1212
{
1313
#if !_WIN32
14-
Debug.Log("UNITYSDK: " + message);
14+
//Debug.Log("UNITYSDK: " + message);
1515
#endif
1616
}
1717
}

AgoraChatSDK/AgoraChat/Native/NativeListener.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using AgoraChat.SimpleJSON;
22
using System;
33
using System.Runtime.InteropServices;
4+
#if !_WIN32
5+
using UnityEngine;
6+
#endif
47

58
namespace AgoraChat
69
{
@@ -104,18 +107,14 @@ internal NativeListener()
104107
};
105108
}
106109

107-
internal class MonoPInvokeCallbackAttribute : Attribute
108-
{
109-
public MonoPInvokeCallbackAttribute(Type t) { }
110-
}
111-
112-
[MonoPInvokeCallback(typeof(NativeListenerEvent))]
110+
#if !_WIN32
111+
[AOT.MonoPInvokeCallback(typeof(NativeListenerEvent))]
113112
public static void OnRunCallback(string listener, string method, string jsonString)
114113
{
115114
LogPrinter.Log($"OnRunCallback listener: {listener}, method: {method}, jsonString: {jsonString}");
116115
SDKClient.Instance._clientImpl.nativeListener.nativeListenerEvent?.Invoke(listener, method, jsonString);
117116
}
118-
117+
#endif
119118
~NativeListener()
120119
{
121120
queue_worker.ClearQueue();

UnityChatDemo/Assets/AgoraChat/AgoraChat/Helper/LogPrinter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class LogPrinter
1111
public static void Log(object message)
1212
{
1313
#if !_WIN32
14-
Debug.Log("UNITYSDK: " + message);
14+
//Debug.Log("UNITYSDK: " + message);
1515
#endif
1616
}
1717
}

UnityChatDemo/Assets/AgoraChat/AgoraChat/Native/NativeListener.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using AgoraChat.SimpleJSON;
22
using System;
33
using System.Runtime.InteropServices;
4+
#if !_WIN32
5+
using UnityEngine;
6+
#endif
47

58
namespace AgoraChat
69
{
@@ -104,18 +107,14 @@ internal NativeListener()
104107
};
105108
}
106109

107-
internal class MonoPInvokeCallbackAttribute : Attribute
108-
{
109-
public MonoPInvokeCallbackAttribute(Type t) { }
110-
}
111-
112-
[MonoPInvokeCallback(typeof(NativeListenerEvent))]
110+
#if !_WIN32
111+
[AOT.MonoPInvokeCallback(typeof(NativeListenerEvent))]
113112
public static void OnRunCallback(string listener, string method, string jsonString)
114113
{
115114
LogPrinter.Log($"OnRunCallback listener: {listener}, method: {method}, jsonString: {jsonString}");
116115
SDKClient.Instance._clientImpl.nativeListener.nativeListenerEvent?.Invoke(listener, method, jsonString);
117116
}
118-
117+
#endif
119118
~NativeListener()
120119
{
121120
queue_worker.ClearQueue();

0 commit comments

Comments
 (0)