/// <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); }
/// <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)); }
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); }
/// <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; } }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <summary> /// Performs async operation. /// </summary> private Task DoOutOpAsync <T1>(CacheOp op, T1 val1) { return(DoOutOpAsync <object, T1>((int)op, val1)); }
/// <summary> /// Does the out op. /// </summary> private bool DoOutOp(CacheOp op, Action <BinaryWriter> write) { return(DoOutInOpX((int)op, write, _readException)); }
/// <summary> /// Performs async operation. /// </summary> private Task DoOutOpAsync(CacheOp op, Action <BinaryWriter> writeAction = null) { return(DoOutOpAsync <object>(op, writeAction)); }
/// <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)); }
/// <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)); }
/// <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)); }
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); }
public void UpdateAll(DateTime?updateTime = null) { var upTime = updateTime ?? DateTime.Now; CacheOp.SetNeedUpdate(EntityType, upTime); }
/// <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)); }
public void UpdateById(string keyId, DateTime?updateTime = null) { var upTime = updateTime ?? DateTime.Now; CacheOp.SetNeedUpdate(EntityType, upTime, keyId); }