Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
.DS_Store
**/.idea
**/.DS_Store
**/xcuserdata
10 changes: 10 additions & 0 deletions empty-project/Assets/Plugins/Android/FirebaseAndroidImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ public AuthData Auth {
return new AuthData(token, uid, expiration);
}
}

public void GoOffline ()
{
GetJavaObject ().CallStatic ("goOffline");
}

public void GoOnline ()
{
GetJavaObject ().CallStatic ("goOnline");
}
#endregion

class CompletionListener : AndroidJavaProxy {
Expand Down
15 changes: 15 additions & 0 deletions empty-project/Assets/Plugins/Editor/FirebaseEditorImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ private static extern void _FirebaseAuthWithOAuthToken (IntPtr firebase, string
private static extern long _FirebaseGetAuthExpiration(IntPtr firebase);
[DllImport ("FirebaseProxy")]
private static extern void _FirebaseUnAuth(IntPtr firebase);

[DllImport ("FirebaseProxy")]
private static extern void _FirebaseGoOffline();
[DllImport ("FirebaseProxy")]
private static extern void _FirebaseGoOnline();

#endregion

Expand Down Expand Up @@ -220,6 +225,16 @@ public AuthData Auth {
_FirebaseGetAuthExpiration(GetEditorObject()));
}
}

public void GoOffline ()
{
_FirebaseGoOffline ();
}

public void GoOnline ()
{
_FirebaseGoOnline ();
}

#endregion

Expand Down
3 changes: 3 additions & 0 deletions empty-project/Assets/Plugins/Firebase/IFirebase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ public interface IFirebase : IQuery

void UnAuth();
AuthData Auth { get; }

void GoOffline ();
void GoOnline ();
}
8 changes: 8 additions & 0 deletions empty-project/Assets/Plugins/iOS/Firebase.mm
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ void _FirebaseUnAuth( void* firebase) {
[myFirebaseRef unauth];
}

void _FirebaseGoOffline() {
[Firebase goOffline];
}

void _FirebaseGoOnline() {
[Firebase goOnline];
}

float _DataSnapshotGetFloatValue (void* datasnapshot) {
FDataSnapshot *snapshotRef = (__bridge FDataSnapshot*) (datasnapshot);
return [[snapshotRef value] floatValue];
Expand Down
16 changes: 16 additions & 0 deletions empty-project/Assets/Plugins/iOS/FirebaseiOSImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ private static extern void _FirebaseAuthWithOAuthToken (IntPtr firebase, string
[DllImport ("__Internal")]
private static extern void _FirebaseUnAuth( IntPtr firebase);

[DllImport ("__Internal")]
private static extern void _FirebaseGoOffline();

[DllImport ("__Internal")]
private static extern void _FirebaseGoOnline();

#endregion

#region IFirebase implementation
Expand Down Expand Up @@ -236,6 +242,16 @@ public AuthData Auth {
}
}

public void GoOffline ()
{
_FirebaseGoOffline ();
}

public void GoOnline ()
{
_FirebaseGoOnline ();
}

#endregion

[MonoPInvokeCallbackAttribute(typeof(OnAuthSuccessHandler))]
Expand Down
Binary file removed source/.DS_Store
Binary file not shown.
Binary file removed source/XCodePlugin/.DS_Store
Binary file not shown.
18 changes: 18 additions & 0 deletions source/XCodePlugin/JniFirebase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,22 @@ void JniFirebase::UnAuth() {
env->CallVoidMethod(m_firebase, s_unAuth);
}

jmethodID JniFirebase::s_goOffline = NULL;
void JniFirebase::GoOffline() {
auto env = getEnv();
if (!GetStaticMethod(env, s_firebaseClass, "goOffline", "()V",
&s_goOffline)) {
return;
}
env->CallStaticVoidMethod(NULL, s_goOffline);
}

jmethodID JniFirebase::s_goOnline = NULL;
void JniFirebase::GoOnline() {
auto env = getEnv();
if (!GetMethod(env, s_firebaseClass, "goOnline", "()V",
&s_goOnline)) {
return;
}
env->CallStaticVoidMethod(NULL, s_goOnline);
}
7 changes: 6 additions & 1 deletion source/XCodePlugin/JniFirebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class JniFirebase {
uint64_t GetAuthExpiration();

void UnAuth();

static void GoOffline();
static void GoOnline();

jobject getJniObject() {
return m_firebase;
Expand Down Expand Up @@ -123,7 +126,9 @@ class JniFirebase {

static jmethodID s_firebaseGetAuth;


static jmethodID s_unAuth;

static jmethodID s_goOffline;
static jmethodID s_goOnline;
};
#endif /* defined(__XCodePlugin__JniFirebase__) */
16 changes: 16 additions & 0 deletions source/XCodePlugin/JniHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ bool GetMethod(JNIEnv* env, jclass clazz, const char* methodName, const char* me
return (*pMethod) != NULL;
}

inline
bool GetStaticMethod(JNIEnv* env, jclass clazz, const char* methodName, const char* methodSig, jmethodID* pMethod) {
if (!env) {
return false;
}
if (*pMethod) {
return true;
}
lock<std::mutex> lock(g_lock);
if (*pMethod) {
return true;
}
*pMethod = env->GetStaticMethodID(clazz, methodName, methodSig);
return (*pMethod) != NULL;
}

const char* CallToString(JNIEnv* env, jobject localRef) ;

const char* GetJNIExceptionDescription(JNIEnv* env, jthrowable exception );
Expand Down
12 changes: 12 additions & 0 deletions source/XCodePlugin/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ void _FirebaseUnAuth(void* firebase) {
jniFirebase->UnAuth();
}

void _FirebaseGoOffline(void* firebase) {
if (!firebase) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you probably dont need the firebase instance if these are statics.
But if it doesn't hurt... its not bad to keep the pattern the same.

Were you able to recompile the libs to test? It's a bit complicated as the bundle for editor/mac needs to be compiled in XCode and the same code is compiled in Visual Studio for windows/editor.

JniFirebase* jniFirebase = (JniFirebase*) firebase;
jniFirebase->GoOffline();
}

void _FirebaseGoOnline(void* firebase) {
if (!firebase) return;
JniFirebase* jniFirebase = (JniFirebase*) firebase;
jniFirebase->GoOnline();
}

float _DataSnapshotGetFloatValue (void* datasnapshot) {
if (!datasnapshot) return 0;
JniDataSnapshot* jniDataSnapshot = (JniDataSnapshot*)datasnapshot;
Expand Down