internal TestableOfflineManager(AbstractProtocol networkProtocol, KuzzleSdk.IKuzzle kuzzle) : base(networkProtocol, kuzzle)
 {
     MaxQueueSize           = -1;
     MaxRequestDelay        = 1000;
     MinTokenDuration       = 3600000;
     RefreshedTokenDuration = 3600000;
     QueueFilter            = null;
 }
Beispiel #2
0
 internal OfflineManager(AbstractProtocol networkProtocol, IKuzzle kuzzle)
 {
     this.NetworkProtocol          = networkProtocol;
     networkProtocol.StateChanged += this.StateChangeListener;
     this.kuzzle = kuzzle;
     InitComponents();
     this.kuzzle.GetEventHandler().UserLoggedIn  += this.OnUserLoggedIn;
     this.kuzzle.GetEventHandler().UserLoggedOut += this.OnUserLoggedOut;
 }
        public void testGetMessage()
        {
            JsonObject message = JsonObject.Parse("{\"hello\": \"world\"}") as JsonObject;

            Context context = TestHelpers.getContext();

            byte[] packedMessage = AbstractProtocol.packMsg(context, message);

            JsonObject unpackedMessage = TestHelpers.unpackForwardMessage(context, packedMessage);

            Assert.AreEqual(unpackedMessage["hello"].ToString(), "\"world\"");

            TestHelpers.cleanup(context);
        }
Beispiel #4
0
        /// <summary>
        /// Initialize a new instance of the <see cref="T:Kuzzle.Kuzzle"/> class.
        /// </summary>
        public Kuzzle(
            AbstractProtocol networkProtocol,
            int refreshedTokenDuration       = 3600000,
            int minTokenDuration             = 3600000,
            int maxQueueSize                 = -1,
            int maxRequestDelay              = 1000,
            bool autoRecover                 = false,
            Func <JObject, bool> queueFilter = null
            )
        {
            NetworkProtocol = networkProtocol;
            NetworkProtocol.ResponseEvent += ResponsesListener;
            NetworkProtocol.StateChanged  += StateChangeListener;

            EventHandler = new KuzzleEventHandler(this);

            // Initializes the controllers
            Auth       = new AuthController(this);
            Collection = new CollectionController(this);
            Document   = new DocumentController(this);
            Index      = new IndexController(this);
            Realtime   = new RealtimeController(this);
            Server     = new ServerController(this);
            Bulk       = new BulkController(this);
            Admin      = new AdminController(this);

            Offline = new OfflineManager(networkProtocol, this)
            {
                RefreshedTokenDuration = refreshedTokenDuration,
                MinTokenDuration       = minTokenDuration,
                MaxQueueSize           = maxQueueSize,
                MaxRequestDelay        = maxRequestDelay,
                QueueFilter            = queueFilter,
                AutoRecover            = autoRecover
            };

            // Initializes instance unique properties
            Version = typeof(Kuzzle)
                      .GetTypeInfo()
                      .Assembly
                      .GetName()
                      .Version
                      .ToString();

            InstanceId = Guid.NewGuid().ToString();

            SdkName = $"csharp@{Version}";
        }
Beispiel #5
0
        /// <summary>
        /// Creates the control message without packaging and sending it.
        /// </summary>
        /// <param name="context">an instance of the Context object initialized to a verity-application agent</param>
        /// <returns>the constructed message (JSON object)</returns>
        public JsonObject provisionMsg(Context context)
        {
            if (context == null)
            {
                throw new UndefinedContextException("Context cannot be NULL");
            }

            JsonObject rtn = new JsonObject();

            rtn.Add("@id", AbstractProtocol.getNewId());
            rtn.Add("@type", messageType(CREATE_EDGE_AGENT));
            rtn.Add("requesterVk", context.SdkVerKey());

            if (token != null)
            {
                var tokenObj = JsonObject.Parse(token) as JsonObject;
                rtn.Add("provisionToken", tokenObj);
            }

            return(rtn);
        }
 public void Write(AbstractProtocol protocol) => serializer.Encapsulate(protocol);