Exemple #1
0
        /// <summary>
        /// Gets and resets task for previous asynchronous operation.
        /// </summary>
        /// <typeparam name="TResult">The type of the result.</typeparam>
        /// <param name="lastAsyncOp">The last async op id.</param>
        /// <param name="converter">The converter.</param>
        /// <returns>
        /// Task for previous asynchronous operation.
        /// </returns>
        private Task <TResult> GetTask <TResult>(CacheOp lastAsyncOp, Func <BinaryReader, TResult> converter = null)
        {
            Debug.Assert(_flagAsync);

            return(GetFuture((futId, futTypeId) => UU.TargetListenFutureForOperation(Target, futId, futTypeId,
                                                                                     (int)lastAsyncOp), _flagKeepBinary, converter).Task);
        }
Exemple #2
0
 /// <summary>
 /// Does the out-in op.
 /// </summary>
 private CacheResult <TV> DoOutInOpNullable(CacheOp cacheOp, TK x)
 {
     return(DoOutInOpX((int)cacheOp,
                       w => w.Write(x),
                       (stream, res) => res == True ? new CacheResult <TV>(Unmarshal <TV>(stream)) : new CacheResult <TV>(),
                       _readException));
 }
Exemple #3
0
        public void UpdateComplateByKey(string key)
        {
            var    array = key.Split('|');
            string entityType = array[0], keyId = array[1], keyValue = array[2];

            CacheOp.ComplateUpdate(entityType, keyId, keyValue, DateTime.Now);
        }
Exemple #4
0
 /// <summary>
 /// Does the out op.
 /// </summary>
 private bool DoOutOp <T1>(CacheOp op, T1 x)
 {
     return(DoOutInOpX((int)op, w =>
     {
         w.Write(x);
     }, _readException));
 }
 /// <summary>
 /// Sets the last asynchronous op id.
 /// </summary>
 /// <param name="opId">The op identifier.</param>
 private void SetLastAsyncOp(CacheOp opId)
 {
     if (IsAsync)
     {
         _lastAsyncOp.Value = (int)opId;
     }
 }
Exemple #6
0
 /// <summary>
 /// Does the out op.
 /// </summary>
 private bool DoOutOp <T1, T2>(CacheOp op, T1 x, T2 y)
 {
     return(DoOutInOpX((int)op, w =>
     {
         w.WriteObjectDetached(x);
         w.WriteObjectDetached(y);
     }, _readException));
 }
Exemple #7
0
 /// <summary>
 /// Does the out op.
 /// </summary>
 private bool DoOutOp <T1, T2>(CacheOp op, T1 x, T2 y)
 {
     return(DoOutInOpX((int)op, w =>
     {
         w.Write(x);
         w.Write(y);
     }, ReadException));
 }
Exemple #8
0
 /// <summary>
 /// Does the out op.
 /// </summary>
 private bool DoOutOp <T1, T2, T3>(CacheOp op, T1 x, T2 y, T3 z)
 {
     return(DoOutInOpX((int)op, w =>
     {
         w.Write(x);
         w.Write(y);
         w.Write(z);
     }, _readException));
 }
Exemple #9
0
 /// <summary>
 /// Does the out-in op.
 /// </summary>
 private CacheResult <TV> DoOutInOpNullable <T1, T2>(CacheOp cacheOp, T1 x, T2 y)
 {
     return(DoOutInOpX((int)cacheOp,
                       w =>
     {
         w.WriteObjectDetached(x);
         w.WriteObjectDetached(y);
     },
                       (stream, res) => res == True ? new CacheResult <TV>(Unmarshal <TV>(stream)) : new CacheResult <TV>(),
                       _readException));
 }
Exemple #10
0
 /// <summary>
 /// Performs async operation.
 /// </summary>
 private Task DoOutOpAsync <T1>(CacheOp op, T1 val1)
 {
     return(DoOutOpAsync <object, T1>((int)op, val1));
 }
Exemple #11
0
 /// <summary>
 /// Does the out op.
 /// </summary>
 private bool DoOutOp(CacheOp op, Action <BinaryWriter> write)
 {
     return(DoOutInOpX((int)op, write, _readException));
 }
Exemple #12
0
 /// <summary>
 /// Performs async operation.
 /// </summary>
 private Task DoOutOpAsync(CacheOp op, Action <BinaryWriter> writeAction = null)
 {
     return(DoOutOpAsync <object>(op, writeAction));
 }
Exemple #13
0
 /// <summary>
 /// Performs async operation.
 /// </summary>
 private Task <TR> DoOutOpAsync <T1, T2, TR>(CacheOp op, T1 val1, T2 val2)
 {
     return(DoOutOpAsync <T1, T2, TR>((int)op, val1, val2));
 }
Exemple #14
0
 /// <summary>
 /// Performs async operation.
 /// </summary>
 private Task DoOutOpAsync <T1, T2>(CacheOp op, T1 val1, T2 val2)
 {
     return(DoOutOpAsync <T1, T2, object>((int)op, val1, val2));
 }
Exemple #15
0
 /// <summary>
 /// Gets and resets task for previous asynchronous operation.
 /// </summary>
 /// <param name="lastAsyncOp">The last async op id.</param>
 /// <returns>
 /// Task for previous asynchronous operation.
 /// </returns>
 private Task GetTask(CacheOp lastAsyncOp)
 {
     return(GetTask <object>(lastAsyncOp));
 }
Exemple #16
0
        public override void OnRaiseEvent(IRaiseEventCallInfo info)
        {
            if (this.log == null)
            {
                this.log = this.PluginHost.CreateLogger(this.Name);
            }

            this.log.DebugFormat("Raise event code {0}", info.Request.EvCode);

            string errorMsg;

            if (info.Request.EvCode == 1)
            {
                var cacheOp = new CacheOp(CacheOperations.AddToRoomCache, 0, 255, new Hashtable {
                    { "x", "y" }
                });
                if (!this.PluginHost.ExecuteCacheOperation(cacheOp, out errorMsg))
                {
                    this.PluginHost.BroadcastErrorInfoEvent(errorMsg, info, new SendParameters());
                }
            }
            else if (info.Request.EvCode == 2)
            {
                // add event from this actor
                var cacheOp = new CacheOp(CacheOperations.AddToRoomCache, 0, 252, new Hashtable {
                    { "a", "v" }
                })
                {
                    ActorNr = info.ActorNr
                };
                if (!this.PluginHost.ExecuteCacheOperation(cacheOp, out errorMsg))
                {
                    this.PluginHost.BroadcastErrorInfoEvent(errorMsg, info, new SendParameters());
                }
            }
            else if (info.Request.EvCode == 3)
            {
                this.log.DebugFormat("if for code {0} performed", info.Request.EvCode);
                // remove all for actors who left game
                var cacheOp = new CacheOp(CacheOperations.RemoveFromCacheForActorsLeft);
                if (!this.PluginHost.ExecuteCacheOperation(cacheOp, out errorMsg))
                {
                    this.PluginHost.BroadcastErrorInfoEvent(errorMsg, info, new SendParameters());
                }
            }
            else if (info.Request.EvCode == 4)
            {
                // remove all from actor 1
                var cacheOp = new CacheOp(CacheOperations.RemoveFromRoomCache, new int[] { 1 }, 0, null);
                if (!this.PluginHost.ExecuteCacheOperation(cacheOp, out errorMsg))
                {
                    this.PluginHost.BroadcastErrorInfoEvent(errorMsg, info, new SendParameters());
                }
            }
            else if (info.Request.EvCode == 5)
            {
                // remove all
                var cacheOp = new CacheOp(CacheOperations.RemoveFromRoomCache, null, 0, null);
                if (!this.PluginHost.ExecuteCacheOperation(cacheOp, out errorMsg))
                {
                    this.PluginHost.BroadcastErrorInfoEvent(errorMsg, info, new SendParameters());
                }
            }


            base.OnRaiseEvent(info);
        }
Exemple #17
0
        public void UpdateAll(DateTime?updateTime = null)
        {
            var upTime = updateTime ?? DateTime.Now;

            CacheOp.SetNeedUpdate(EntityType, upTime);
        }
Exemple #18
0
 /// <summary>
 /// Performs async operation.
 /// </summary>
 private Task <T> DoOutOpAsync <T>(CacheOp op, Action <BinaryWriter> writeAction = null,
                                   Func <BinaryReader, T> convertFunc            = null)
 {
     return(DoOutOpAsync((int)op, writeAction, IsKeepBinary, convertFunc));
 }
Exemple #19
0
        public void UpdateById(string keyId, DateTime?updateTime = null)
        {
            var upTime = updateTime ?? DateTime.Now;

            CacheOp.SetNeedUpdate(EntityType, upTime, keyId);
        }