Example #1
0
 public void SyncClient(IpcSyncClientMsg msg)
 {
     ConsoleEx.DebugLog(war.Side.ToString() + " Sub Received : SyncClient.", ConsoleEx.YELLOW);
     if (msg != null)
     {
         cliMonitor.PullClientInfo(msg.AsyncClient);
     }
 }
Example #2
0
        public MonitorClient() : base()
        {
            CharactorPool      = new WarServerCharactor();
            sync               = new IpcSyncClientMsg();
            validateSyncClient = false;

            stopwatch = Stopwatch.StartNew();

            ///
            /// 因为NetMq的缘故,所有的对Dictionary,只有NetMq线程写入, Timer线程只负责读
            ///
            readerWriterLock = new ReaderWriterLockSlim();

            task         = new TimerTask(TimerTask.RIGHTNOW, TimerTask.INFINITY, 1);
            task.onEvent = checkClientStatus;
            task.DispatchToRealHandler();
        }
Example #3
0
        /// <summary>
        /// 所有消息的处理地方
        /// </summary>
        /// <param name="msg">Message.</param>
        void HandleIpcMsg(IpcMsg msg)
        {
            if (msg != null)
            {
                switch (msg.op)
                {
                case OP.CtorMap:
                    IpcCreateMapMsg ctor = msg as IpcCreateMapMsg;
                    MapInfo         amap = new MapInfo()
                    {
                        ID   = ctor.MapId,
                        type = (ConfigType)Enum.ToObject(typeof(ConfigType), ctor.MapType),
                    };
                    CtorEnv(amap);
                    break;

                case OP.CtorNpc:
                    IpcCreateNpcMsg ctorNpc = msg as IpcCreateNpcMsg;
                    CtorNpc(ctorNpc);
                    break;

                case OP.CtorHero:
                    IpcCreateHeroMsg crtHero = msg as IpcCreateHeroMsg;
                    CtorHero(crtHero);
                    break;

                case OP.NpcMove:
                    IpcNpcMoveMsg moveMsg = msg as IpcNpcMoveMsg;
                    NPCMove(moveMsg);
                    break;

                case OP.NpcHp:
                    IpcNpcHpMsg hpMsg = msg as IpcNpcHpMsg;
                    NPChp(hpMsg);
                    break;

                case OP.NpcAnim:
                    IpcNpcAnimMsg animMsg = msg as IpcNpcAnimMsg;
                    NPCAnim(animMsg);
                    break;

                case OP.NpcStatus:
                    IpcNpcStatusMsg statusMsg = msg as IpcNpcStatusMsg;
                    NPCStatus(statusMsg);
                    break;

                case OP.ServerReady:
                    IpcServerReadyMsg SerInfo = msg as IpcServerReadyMsg;
                    ServerInfo        server  = new ServerInfo(SerInfo);
                    ServerReady(server);
                    break;

                case OP.AsyncClient:
                    IpcSyncClientMsg Sync = msg as IpcSyncClientMsg;
                    SyncClient(Sync);
                    break;

                case OP.EnterWar:
                    IpcEnterWar enter   = msg as IpcEnterWar;
                    ServerInfo  aserver = new ServerInfo()
                    {
                        ServerName = enter.ServerName,
                        ServerID   = enter.ServerID,
                    };
                    MapInfo map = new MapInfo()
                    {
                        ID   = enter.MapId,
                        type = (ConfigType)Enum.ToObject(typeof(ConfigType), enter.MapType),
                    };
                    EnterWar(aserver, map);
                    break;

                case OP.ServerQuit:
                    IpcServerQuitMsg quit = msg as IpcServerQuitMsg;
                    ServerQuit(quit.ServerID);
                    break;

                case OP.DestroyNpc:
                    IpcDestroyNpcMsg des = msg as IpcDestroyNpcMsg;
                    NpcDestroy(des);
                    break;

                case OP.SkillCD:
                    IpcSkillMsg skMsg = msg as IpcSkillMsg;
                    NpcSkillCD(skMsg);
                    break;
                }
            }
        }
Example #4
0
 /// <summary>
 /// 发送给客户端的同步数据
 /// </summary>
 /// <param name="msg">Message.</param>
 public void SyncClient(IpcSyncClientMsg msg)
 {
     publisher.send(msg);
 }