Skip to content

Commit

Permalink
Merge pull request #169 from luckyyuqiang/new
Browse files Browse the repository at this point in the history
Replace custom MonoPInvokeCallback with AOT attribute.
  • Loading branch information
dujiepeng authored Jan 16, 2023
2 parents 68b4a3b + efc1cf7 commit 3d183ea
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion AgoraChatSDK/AgoraChat/Helper/LogPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class LogPrinter
public static void Log(object message)
{
#if !_WIN32
Debug.Log("UNITYSDK: " + message);
//Debug.Log("UNITYSDK: " + message);
#endif
}
}
Expand Down
13 changes: 6 additions & 7 deletions AgoraChatSDK/AgoraChat/Native/NativeListener.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using AgoraChat.SimpleJSON;
using System;
using System.Runtime.InteropServices;
#if !_WIN32
using UnityEngine;
#endif

namespace AgoraChat
{
Expand Down Expand Up @@ -104,18 +107,14 @@ internal NativeListener()
};
}

internal class MonoPInvokeCallbackAttribute : Attribute
{
public MonoPInvokeCallbackAttribute(Type t) { }
}

[MonoPInvokeCallback(typeof(NativeListenerEvent))]
#if !_WIN32
[AOT.MonoPInvokeCallback(typeof(NativeListenerEvent))]
public static void OnRunCallback(string listener, string method, string jsonString)
{
LogPrinter.Log($"OnRunCallback listener: {listener}, method: {method}, jsonString: {jsonString}");
SDKClient.Instance._clientImpl.nativeListener.nativeListenerEvent?.Invoke(listener, method, jsonString);
}

#endif
~NativeListener()
{
queue_worker.ClearQueue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class LogPrinter
public static void Log(object message)
{
#if !_WIN32
Debug.Log("UNITYSDK: " + message);
//Debug.Log("UNITYSDK: " + message);
#endif
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using AgoraChat.SimpleJSON;
using System;
using System.Runtime.InteropServices;
#if !_WIN32
using UnityEngine;
#endif

namespace AgoraChat
{
Expand Down Expand Up @@ -104,18 +107,14 @@ internal NativeListener()
};
}

internal class MonoPInvokeCallbackAttribute : Attribute
{
public MonoPInvokeCallbackAttribute(Type t) { }
}

[MonoPInvokeCallback(typeof(NativeListenerEvent))]
#if !_WIN32
[AOT.MonoPInvokeCallback(typeof(NativeListenerEvent))]
public static void OnRunCallback(string listener, string method, string jsonString)
{
LogPrinter.Log($"OnRunCallback listener: {listener}, method: {method}, jsonString: {jsonString}");
SDKClient.Instance._clientImpl.nativeListener.nativeListenerEvent?.Invoke(listener, method, jsonString);
}

#endif
~NativeListener()
{
queue_worker.ClearQueue();
Expand Down

0 comments on commit 3d183ea

Please sign in to comment.