static public CmdContext Get(uint pKey)
        {
            CmdContext _ctx = null;

            if (cache.ContainsKey(pKey))
            {
                _ctx = (CmdContext)cache[pKey];
            }
            return(_ctx);
        }
        static public bool Save(uint pKey, CmdContext pRequestCtx)
        {
            if (cache.ContainsKey(pKey))
            {
                throw new Exception(string.Format("CmdContextCache.Save: Key={0}, in USE", pKey));
            }

            cache.Add(pKey, pRequestCtx);
            return(true);
        }
Exemple #3
0
		// we are on our own thread from the IOCP thread pool:
		void dispatcher(uint pIndex) {
			CmdContext _cmdCtx = null;
			try {
				_cmdCtx = CmdContextCache.Get(pIndex);

				var _cmd = commandFactory.GetCommand(_cmdCtx.DataReceived);
				_cmd.Execute();
				_cmd.SendResponse(localHost, _cmdCtx.RmtEndPoint);
			}
			catch (Exception _ex) {
				log(LogSeverity.Critical, UDP_SERVER_DISPATCHER_LABEL, string.Format("Exception:\r\n{0}", _ex));
				if (_cmdCtx != null) {
					log(LogSeverity.Status, UDP_SERVER_DISPATCHER_LABEL, string.Format("Exception:\r\n{0}", _cmdCtx.DataReceived));
				}
			}
			finally {
				CmdContextCache.Remove(pIndex);
			}
		}