Exemplo n.º 1
0
        public void Service(ProtocolQueue model)
        {
#if DEBUG
            XTrace.WriteLine("commandNumber:{0}", model.Protocol.commandNumber);
#endif
            try
            {
                if (model.Session == null)
                {
                    return;
                }
                TGGSession session = model.Session;

                var key = string.Format("{0}_{1}_{2}", session.Player.User.id, model.Protocol.moduleNumber, model.Protocol.commandNumber);
                if (Variable.CCI.ContainsKey(key))
                {
                    //session.SendData(session.InitProtocol(model, (int)ResponseType.TYPE_COMMAND_FAST, null));
                    return;
                }
                Variable.CCI.TryAdd(key, true);

                var cs   = new CommandSwitch();
                var data = cs.Switch(model.Protocol.commandNumber, session, model.Protocol.data);
                cs.Dispose();
                if (data == null)
                {
                    XTrace.WriteLine("指令错误:{0}", key); RemoveCommand(key); return;
                }
                var pv = session.InitProtocol(model, (int)ResponseType.TYPE_SUCCESS, data);
                session.SendData(pv);
                RemoveCommand(key);
            }
            catch (Exception ex)
            {
                XTrace.WriteException(ex);
                if (model.Session != null)
                {
                    model.Session.CommandEnd(model);
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>CommandSwitch单例模式</summary>
 public static CommandSwitch GetInstance()
 {
     return(ObjInstance ?? (ObjInstance = new CommandSwitch()));
 }