Exemple #1
0
        private void GenerateSyncRes(ref Responses res, string newop)
        {
            Parameters syncPm = new Parameters(2);

            syncPm.AddParam(0, this.payload.PVector);
            syncPm.AddParam(1, this.payload.NVector);

            string broadcast = Parser.BuildCommand(this.typecode, "y", this.uid, syncPm);

            res.AddResponse(Dest.broadcast, broadcast, false);
        }
Exemple #2
0
        public void Sync(string newop, int status = 0)
        {
            DEBUG("Syncing new op " + newop);

            Responses  res    = new Responses(Status.success);
            Parameters syncPm = new Parameters(2);

            syncPm.AddParam(0, newop);
            syncPm.AddParam(1, status);
            string broadcast = Parser.BuildCommand("h", "y", this.uid, syncPm);

            res.AddResponse(Dest.broadcast, broadcast, false);
            Global.server.StageResponse(res);
        }
Exemple #3
0
        /// <summary>
        /// Called on every update of CRDT OP to
        /// synchronize the history
        /// </summary>
        /// <param name="newop"></param>
        /// <param name="status">0 = op, 1 = tombstone, 2 = related</param>
        public void Sync(StateHisotryEntry newop, int status = 0)
        {
            DEBUG("Syncing new op " + newop.opid);
            string json = JsonConvert.SerializeObject(newop, Formatting.Indented);

            Responses  res    = new Responses(Status.success);
            Parameters syncPm = new Parameters(2);

            syncPm.AddParam(0, json);
            syncPm.AddParam(1, status);
            string broadcast = Parser.BuildCommand("h", "y", this.uid, syncPm);

            res.AddResponse(Dest.broadcast, broadcast, false);
            Global.server.StageResponse(res);
        }
Exemple #4
0
        public override Responses SetValue()
        {
            Responses res = new Responses(Status.success);

            GCPayload pl = new GCPayload(uid, (int)Config.numReplicas, (int)Config.replicaId);



            pl.valueVector[pl.replicaid] = this.parameters.GetParam <int>(0);

            this.payload = pl;

            res.AddResponse(Dest.client);

            Parameters syncPm = new Parameters(1);

            syncPm.AddParam(0, this.payload.valueVector);



            string broadcast = Parser.BuildCommand(this.typecode, "y", this.uid, syncPm);

            res.AddResponse(Dest.broadcast, broadcast, false);


            return(res);
        }
Exemple #5
0
        /// <summary>
        /// Добавить параметр объекта
        /// </summary>
        /// <param name="luaName">Lua-имя</param>
        /// <param name="name">Отображаемое название</param>
        /// <param name="value">Значение</param>
        /// <param name="meter">Единица измерения</param>
        public void AddParameter(string luaName, string name, double value,
                                 string meter)
        {
            var parameter = new Param(Parameters.GetIdx, name, false, value,
                                      meter, luaName, true);

            Parameters.AddParam(parameter);
        }
Exemple #6
0
        public Responses Increment()
        {
            this.payload.valueVector[this.payload.replicaid] += this.parameters.GetParam <int>(0);

            Responses res = new Responses(Status.success);

            Parameters syncPm = new Parameters(1);

            syncPm.AddParam(0, this.payload.valueVector);

            string broadcast = Parser.BuildCommand(this.typecode, "y", this.uid, syncPm);

            res.AddResponse(Dest.client);
            res.AddResponse(Dest.broadcast, broadcast, false);

            return(res);
        }