Example #1
0
        protected virtual int create(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender)
        {
            ClientObject client = (ClientObject)sender.ClientObject;

            client.CurrentDeploy = new DeployInfo(client, deployIndex);
            return(deployIndex++);
        }
Example #2
0
        public static bool InitializeClient(AutoCSer.Net.TcpInternalServer.ServerSocketSender socket, KuaFuClientContext clientInfo)
        {
            bool isLogin = false;

            try
            {
                if (clientInfo.ServerId != 0)
                {
                    bool bFirstInit = false;
                    int  ret        = ClientAgentManager.Instance().InitializeClient(clientInfo, out bFirstInit);
                    if (ret > 0)
                    {
                        isLogin             = true;
                        socket.ClientObject = ClientAgentManager.Instance().GetCurrentClientAgent(clientInfo.ServerId);
                        if (clientInfo.MapClientCountDict != null && clientInfo.MapClientCountDict.Count > 0)
                        {
                            KuaFuServerManager.UpdateKuaFuLineData(clientInfo.ServerId, clientInfo.MapClientCountDict);
                            ClientAgentManager.Instance().SetMainlinePayload(clientInfo.ServerId, clientInfo.MapClientCountDict.Values.ToList <int>().Sum());
                        }
                    }
                }
                else
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("InitializeClient时GameType错误,禁止连接.ServerId:{0},GameType:{1}", clientInfo.ServerId, clientInfo.GameType), null, true);
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(string.Format("InitializeClient服务器ID重复,禁止连接.ServerId:{0},ClientId:{1},info:{2}", clientInfo.ServerId, clientInfo.ClientId, clientInfo.Token));
            }
            return(isLogin);
        }
Example #3
0
 private void getLog(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, Func <AutoCSer.Net.TcpServer.ReturnValue <Log>, bool> onLog)
 {
     //object arrayLock = clientPool.ArrayLock;
     //Monitor.Enter(arrayLock);
     //clientPool.Array[clientId.Index].Set(clientId.Identity, onLog);
     //Monitor.Exit(arrayLock);
     ((ClientObject)sender.ClientObject).OnLog = onLog;
 }
Example #4
0
        public static void KeepGetMessage(AutoCSer.Net.TcpInternalServer.ServerSocketSender socket, Func <ReturnValue <KFCallMsg>, bool> onMessage)
        {
            ClientAgent agent = socket.ClientObject as ClientAgent;

            if (null != agent)
            {
                agent.KFCallMsg = onMessage;
            }
        }
Example #5
0
 protected override bool verify(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, string userID, ulong randomPrefix, byte[] md5Data, ref long ticks)
 {
     if (base.verify(sender, userID, randomPrefix, md5Data, ref ticks))
     {
         sender.ClientObject = createClientObject();
         return(true);
     }
     return(false);
 }
Example #6
0
 private bool clear(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, IndexIdentity identity)
 {
     if (checkCommand(sender, Command.clear))
     {
         Clear(ref identity);
         return(true);
     }
     return(false);
 }
Example #7
0
        protected virtual int addAssemblyFiles(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, ClientTask.AssemblyFile assemblyFile)
        {
            DeployInfo deployInfo = ((ClientObject)sender.ClientObject).CurrentDeploy;

            if (deployInfo != null)
            {
                return(deployInfo.AddTask(assemblyFile));
            }
            return(-1);
        }
Example #8
0
        protected virtual int addRun(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, ClientTask.Run run)
        {
            DeployInfo deployInfo = ((ClientObject)sender.ClientObject).CurrentDeploy;

            if (deployInfo != null)
            {
                return(deployInfo.AddTask(run));
            }
            return(-1);
        }
Example #9
0
        protected virtual int addFiles(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, int deployIndex, ClientTask.WebFile webFile)
        {
            DeployInfo deployInfo = ((ClientObject)sender.ClientObject).GetDeploy(deployIndex);

            if (deployInfo != null)
            {
                return(deployInfo.AddTask(webFile));
            }
            return(-1);
        }
Example #10
0
        protected virtual int addUpdateSwitchFile(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, ClientTask.UpdateSwitchFile updateSwitchFile)
        {
            DeployInfo deployInfo = ((ClientObject)sender.ClientObject).CurrentDeploy;

            if (deployInfo != null)
            {
                return(deployInfo.AddTask(updateSwitchFile));
            }
            return(-1);
        }
Example #11
0
        public static void UpdateKuaFuMapClientCount(AutoCSer.Net.TcpInternalServer.ServerSocketSender socket, int serverId, Dictionary <int, int> mapClientCountDict)
        {
            ClientAgent agent = socket.ClientObject as ClientAgent;

            if (mapClientCountDict != null && mapClientCountDict.Count > 0)
            {
                KuaFuServerManager.UpdateKuaFuLineData(agent.ClientInfo.ServerId, mapClientCountDict);
                ClientAgentManager.Instance().SetMainlinePayload(agent.ClientInfo.ServerId, mapClientCountDict.Values.ToList <int>().Sum());
            }
        }
Example #12
0
        protected virtual bool setFileSource(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, byte[][] files)
        {
            DeployInfo deployInfo = ((ClientObject)sender.ClientObject).CurrentDeploy;

            if (deployInfo != null)
            {
                deployInfo.Files = files;
                return(true);
            }
            return(false);
        }
Example #13
0
        protected virtual int addCustom(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, ClientTask.Custom custom)
        {
            DeployInfo deployInfo = ((ClientObject)sender.ClientObject).CurrentDeploy;

            if (deployInfo != null)
            {
                custom.Sender = sender;
                return(deployInfo.AddTask(custom));
            }
            return(-1);
        }
Example #14
0
        protected virtual DeployState start(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, DateTime time)
        {
            DeployInfo deployInfo = ((ClientObject)sender.ClientObject).CurrentDeploy;

            if (deployInfo == null)
            {
                return(DeployState.StartError);
            }
            return(deployInfo.Start(time, new Timer {
                Server = this
            }));
        }
Example #15
0
        protected virtual int addWaitRunSwitch(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, int taskIndex)
        {
            DeployInfo deployInfo = ((ClientObject)sender.ClientObject).CurrentDeploy;

            if (deployInfo != null)
            {
                return(deployInfo.AddTask(new ClientTask.WaitRunSwitch {
                    TaskIndex = taskIndex
                }));
            }
            return(-1);
        }
Example #16
0
        private void customPush(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, Func <AutoCSer.Net.TcpServer.ReturnValue <byte[]>, bool> onPush)
        {
            //onPushs.Add(++onPushIdentity, onPush);
            //if (OnGetPush != null) OnGetPush(onPush, onPushIdentity);
            ClientObject client = (ClientObject)sender.ClientObject;

            client.OnCustomPush = onPush;
            if (OnGetPush != null)
            {
                OnGetPush(client);
            }
        }
Example #17
0
 private bool setFileSource(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, IndexIdentity identity, byte[][] files)
 {
     if ((uint)identity.Index < (uint)deployPool.PoolIndex && checkCommand(sender, Command.setFileSource))
     {
         object arrayLock = deployPool.ArrayLock;
         Monitor.Enter(arrayLock);
         if (deployPool.Array[identity.Index].SetFiles(identity.Identity, files))
         {
             Monitor.Exit(arrayLock);
             return(true);
         }
         Monitor.Exit(arrayLock);
     }
     return(false);
 }
Example #18
0
 private DeployState start(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, IndexIdentity identity, DateTime time)
 {
     if ((uint)identity.Index < (uint)deployPool.PoolIndex && checkCommand(sender, Command.start))
     {
         object arrayLock = deployPool.ArrayLock;
         Monitor.Enter(arrayLock);
         try
         {
             return(deployPool.Array[identity.Index].Start(identity.Identity, time, new Timer {
                 Server = this, Identity = identity
             }));
         }
         finally { Monitor.Exit(arrayLock); }
     }
     return(DeployState.IdentityError);
 }
Example #19
0
 private int addRun(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, IndexIdentity identity, KeyValue <string, int>[] files, ClientTask.Run run)
 {
     if ((uint)identity.Index < (uint)deployPool.PoolIndex && checkCommand(sender, Command.addRun))
     {
         object arrayLock = deployPool.ArrayLock;
         Monitor.Enter(arrayLock);
         try
         {
             return(deployPool.Array[identity.Index].AddTask(identity.Identity, new Task {
                 FileIndexs = files, ServerDirectory = new DirectoryInfo(run.ServerPath), Type = TaskType.Run, RunFileName = run.FileName, RunSleep = run.Sleep, IsWaitRun = run.IsWait
             }));
         }
         finally { Monitor.Exit(arrayLock); }
     }
     return(-1);
 }
Example #20
0
 private int addAssemblyFiles(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, IndexIdentity identity, KeyValue <string, int>[] files, ClientTask.AssemblyFile assemblyFile)
 {
     if ((uint)identity.Index < (uint)deployPool.PoolIndex && checkCommand(sender, Command.addAssemblyFiles))
     {
         object arrayLock = deployPool.ArrayLock;
         Monitor.Enter(arrayLock);
         try
         {
             return(deployPool.Array[identity.Index].AddTask(identity.Identity, new Task {
                 FileIndexs = files, ServerDirectory = new DirectoryInfo(assemblyFile.ServerPath), Type = TaskType.AssemblyFile
             }));
         }
         finally { Monitor.Exit(arrayLock); }
     }
     return(-1);
 }
Example #21
0
 private int addCustom(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, IndexIdentity identity, ClientTask.Custom custom)
 {
     if ((uint)identity.Index < (uint)deployPool.PoolIndex && checkCustom(sender, custom.CallName))
     {
         object arrayLock = deployPool.ArrayLock;
         Monitor.Enter(arrayLock);
         try
         {
             return(deployPool.Array[identity.Index].AddTask(identity.Identity, new Task {
                 Sender = sender, RunFileName = custom.CallName, CustomData = custom.CustomData, Type = TaskType.Custom
             }));
         }
         finally { Monitor.Exit(arrayLock); }
     }
     return(-1);
 }
Example #22
0
 private int addWaitRunSwitch(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, IndexIdentity identity, int taskIndex)
 {
     if ((uint)identity.Index < (uint)deployPool.PoolIndex && checkCommand(sender, Command.addWaitRunSwitch))
     {
         object arrayLock = deployPool.ArrayLock;
         Monitor.Enter(arrayLock);
         try
         {
             return(deployPool.Array[identity.Index].AddTask(identity.Identity, new Task {
                 TaskIndex = taskIndex, Type = TaskType.WaitRunSwitch
             }));
         }
         finally { Monitor.Exit(arrayLock); }
     }
     return(-1);
 }
Example #23
0
 private bool clearAll(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender)
 {
     if (checkCommand(sender, Command.clearAll))
     {
         object arrayLock = deployPool.ArrayLock;
         Monitor.Enter(arrayLock);
         DeployInfo[] deployArray = deployPool.Array;
         int          poolIndex   = deployPool.PoolIndex;
         while (poolIndex != 0)
         {
             deployArray[--poolIndex].Clear();
         }
         deployPool.ClearIndexContinue();
         Monitor.Exit(arrayLock);
         GC.Collect();
         return(true);
     }
     return(false);
 }
Example #24
0
 private int addFiles(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, IndexIdentity identity, Directory directory, ClientTask.WebFile webFile, TaskType taskType)
 {
     //System.IO.FileInfo file = new System.IO.FileInfo(@"ServerDeSerializeError" + AutoCSer.Date.NowTime.Set().Ticks.ToString());
     //System.IO.File.WriteAllBytes(file.FullName, data.ToArray());
     //Console.WriteLine(file.FullName);
     if ((uint)identity.Index < (uint)deployPool.PoolIndex && checkCommand(sender, Command.addFiles))
     {
         object arrayLock = deployPool.ArrayLock;
         Monitor.Enter(arrayLock);
         try
         {
             return(deployPool.Array[identity.Index].AddTask(identity.Identity, new Task {
                 Directory = directory, ServerDirectory = new DirectoryInfo(webFile.ServerPath), Type = taskType
             }));
         }
         finally { Monitor.Exit(arrayLock); }
     }
     return(-1);
 }
Example #25
0
        public static int ZhengBaKuaFuLogin(AutoCSer.Net.TcpInternalServer.ServerSocketSender socket, int zhanDuiID, int gameId, int srcServerID, out ZhanDuiZhengBaFuBenData copyData)
        {
            copyData = null;
            lock (ZhanDuiZhengBa_K.Mutex)
            {
                ZhanDuiZhengBa_K.JoinRolePkData roleData = ZhanDuiZhengBa_K.TodayJoinRoleDatas.Find((ZhanDuiZhengBa_K.JoinRolePkData _r) => _r.ZhanDuiID == zhanDuiID && _r.CurrGameID == gameId);
                ZhanDuiZhengBaPkLogData         logData  = null;
                ZhanDuiZhengBa_K.ThisLoopPkLogs.TryGetValue(gameId, out logData);
                if (roleData == null || logData == null)
                {
                    return(-12);
                }
                if (!roleData.WaitReqEnter)
                {
                    return(-12);
                }
                copyData = roleData.CopyData;
            }
            KuaFuServerInfo serverInfo = KuaFuServerManager.GetKuaFuServerInfo(srcServerID);
            int             result;

            if (null != serverInfo)
            {
                copyData.IPs = new string[]
                {
                    serverInfo.DbIp,
                    serverInfo.DbIp
                };
                copyData.Ports = new int[]
                {
                    serverInfo.DbPort,
                    serverInfo.LogDbPort
                };
                result = 0;
            }
            else
            {
                result = -11000;
            }
            return(result);
        }
Example #26
0
        public static int ZhengBaKuaFuLogin(AutoCSer.Net.TcpInternalServer.ServerSocketSender socket, int zhanDuiID, int gameId, int srcServerID, out EscapeBattleFuBenData copyData)
        {
            copyData = null;
            lock (EscapeBattle_K.Mutex)
            {
                EscapeBattle_K.JoinPkData roleData;
                if (!EscapeBattle_K.JoinDict.TryGetValue(zhanDuiID, out roleData) || roleData.CurrGameID == 0)
                {
                    return(-4006);
                }
                EscapeBattlePkLogData logData = null;
                if (!EscapeBattle_K.ThisLoopPkLogs.TryGetValue(roleData.CurrGameID, out logData))
                {
                    return(-4006);
                }
                copyData = roleData.CopyData;
            }
            KuaFuServerInfo serverInfo = KuaFuServerManager.GetKuaFuServerInfo(srcServerID);
            int             result;

            if (null != serverInfo)
            {
                copyData.IPs = new string[]
                {
                    serverInfo.DbIp,
                    serverInfo.DbIp
                };
                copyData.Ports = new int[]
                {
                    serverInfo.DbPort,
                    serverInfo.LogDbPort
                };
                result = 0;
            }
            else
            {
                result = -11000;
            }
            return(result);
        }
Example #27
0
 private IndexIdentity create(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender)
 {
     if (checkCommand(sender, Command.create))
     {
         ClientObject client = (ClientObject)sender.ClientObject;
         int          index, identity;
         object       arrayLock = deployPool.ArrayLock;
         Monitor.Enter(arrayLock);
         try
         {
             index    = deployPool.GetIndexContinue();
             identity = deployPool.Array[index].Set(client);
         }
         finally { Monitor.Exit(arrayLock); }
         return(new IndexIdentity {
             Index = index, Identity = identity
         });
     }
     return(new IndexIdentity {
         Index = -1
     });
 }
Example #28
0
 protected virtual void customPush(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, AutoCSer.Net.TcpServer.ServerCallback <byte[]> onPush)
 {
     ((ClientObject)sender.ClientObject).OnCustomPush = onPush;
 }
Example #29
0
 protected virtual void getLog(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender, AutoCSer.Net.TcpServer.ServerCallback <Log> onLog)
 {
     ((ClientObject)sender.ClientObject).OnLog = onLog;
 }
Example #30
0
 protected virtual void cancel(AutoCSer.Net.TcpInternalServer.ServerSocketSender sender)
 {
     ((ClientObject)sender.ClientObject).CurrentDeploy = null;
 }