コード例 #1
0
        private void OnReceived(WriteBehavior behavior, string data)
        {
            if (behavior == WriteBehavior.None)
            {
                return;
            }

            var callback = Received;

            if (callback != null)
            {
                JObject result    = JObject.Parse(data);
                string  dataValue = result["data"].Type == JTokenType.Null
                    ? null
                    : result["data"].ToString();

                var args =
                    new FirebaseEventReceivedEventArgs(new FirebaseMessage(behavior,
                                                                           new FirebasePath(result["path"].ToString()),
                                                                           dataValue,
                                                                           null,
                                                                           MessageSouce.Remote));

                callback(this, args);
            }
        }
コード例 #2
0
ファイル: AppFactory.cs プロジェクト: amitla/FirebaseSharp
        internal static FirebaseApp FromJson(string json)
        {
            // after the connect call, make it look like some data has shown up.
            var connection = A.Fake <IFirebaseNetworkConnection>();

            A.CallTo(() => connection.Connect()).Invokes(() =>
            {
                var msg  = new FirebaseMessage(WriteBehavior.Replace, new FirebasePath(), json, null, MessageSouce.Remote);
                var args = new FirebaseEventReceivedEventArgs(msg);

                // do it on a separate thread to make sure we don't ignore
                // locking issues during tests
                Task.Run(() => connection.Received += Raise.With(args));
            });

            return(new FirebaseApp(new Uri("https://example.com/"), connection));
        }
コード例 #3
0
ファイル: SyncDatabase.cs プロジェクト: amitla/FirebaseSharp
 private void ConnectionOnReceived(object sender, FirebaseEventReceivedEventArgs e)
 {
     UpdateLocal(e.Message);
     DrainInitialQueue();
 }