예제 #1
0
        static int Main(string[] args)
        {
            Log.InfoFormat("start at current directory {0}", Directory.GetCurrentDirectory());
            Log.Info("parsing command args");

            if (!ParseCommandLine(args))
            {
                Log.Error("command line parse error");
                return(0);
            }
            Log.InfoFormat("Starting plugin, settings:width:{0},height:{1},url:{2},memfile:{3},inMem:{4},outMem:{5}, WebRtc:{6},Enable GPU:{7}",
                           defWidth, defHeight, defUrl, defFileName, defInFileName, defOutFileName, useWebRTC, EnableGPU);

            Log.InfoFormat("Statring cef runtime");

            if (!CefRintimePrepare(args, temporaryDirectoryPath))
            {
                Log.Error("cef runtime initialisation failed");
                return(0); //immediate exit
            }


            try {
                Log.Info("starting cef worker");
                CefWorker worker = new CefWorker();
                worker.Init(defWidth, defHeight, defUrl);
                Log.Info("Binding shared memory");
                SharedTextureWriter server = new SharedTextureWriter(defFileName, defWidth * defHeight * 4);
                MessageReader       inSrv  = MessageReader.Create(defInFileName, 10000);
                MessageWriter       outSrv = MessageWriter.Create(defOutFileName, 10000);
                Log.Info("complete to bind shared memory, ready and wait");
                var app = new App(worker, server, inSrv, outSrv, false);
                Log.Info("Enter main loop");
                try {
                    while (app.IsRunning)
                    {
                        Application.DoEvents();
                        app.CheckMessage();     //check incoming messages
                    }
                }
                catch (Exception e) {
                    Log.ErrorFormat("abnormal exit main loop{0}", e.Message);
                }

                Log.Info("Exit main loop END DISPOSING ALL");
                worker.Dispose();
                server.Dispose();
                inSrv.Dispose();
                outSrv.Dispose();
            }
            catch (Exception e) {
                Log.ErrorFormat("Unclean exit error {0}", e.Message);
            }
            GC.Collect();
            GC.WaitForFullGCComplete(-1);
            Log.Info("CefRuntime.Shutdown");
            CefRuntime.Shutdown();
            Log.Info("Final exit");
            return(0);
        }
예제 #2
0
        private void RequestGame(int gameId, string gameName)
        {
            try
            {
                var           serverList    = new List <ServerInfo>();
                StringBuilder requestParams = new StringBuilder();
                requestParams.AppendFormat("{0}={1}", "ActionID", 1001);
                requestParams.AppendFormat("&{0}={1}", "GameID", gameId);

                Message msg = new Message();
                using (MessageReader msgReader = MessageReader.Create(serverUrl, requestParams.ToString(), msg))
                {
                    if (msgReader == null)
                    {
                        return;
                    }

                    if (msg.ErrorCode != 10000)
                    {
                        int recordCount = msgReader.RecordCount();

                        for (int i = 0; i < recordCount; i++)
                        {
                            var server = new ServerInfo();
                            msgReader.RecordStart();
                            server.GameID   = gameId;
                            server.GameName = gameName;
                            server.ID       = msgReader.ReadInt();
                            server.Name     = msgReader.ReadString();
                            server.Status   = msgReader.ReadString();
                            server.BaseUrl  = msgReader.ReadString();
                            server.Weight   = msgReader.ReadInt();

                            msgReader.RecordEnd();
                            serverList.Add(server);
                        }
                    }
                    else
                    {
                        Logger.SaveLog(string.Format("Game login monitor >> games {0} service list error", gameName), new Exception(msg.ErrorInfo));
                    }
                }
                foreach (var serverInfo in serverList)
                {
                    ThreadPool.QueueUserWorkItem(RequestServer, serverInfo);
                }
            }
            catch (Exception ex)
            {
                Logger.SaveLog(string.Format("The Game Login surveillance >> read {0} the game hours service list error:", gameName), ex);
                SendToMail(string.Format("读取分服列表异常:{0}", ex.Message));
            }
        }
예제 #3
0
        private void RequestServer(object state)
        {
            if (state is ServerInfo)
            {
                var server = state as ServerInfo;
                //Logger.SaveLog(string.Format("游戏登录监视>>{0}[{1}]请求开始", server.GameName, server.Name));
                StringBuilder requestParams = new StringBuilder();
                requestParams.AppendFormat("{0}={1}", "ActionID", 1004);
                requestParams.AppendFormat("&{0}={1}", "Sid", "");
                requestParams.AppendFormat("&{0}={1}", "Uid", "");
                requestParams.AppendFormat("&{0}={1}", "MobileType", 1);
                requestParams.AppendFormat("&{0}={1}", "Pid", GameLogin_Id);
                requestParams.AppendFormat("&{0}={1}", "Pwd", GameLogin_pwd);
                requestParams.AppendFormat("&{0}={1}", "DeviceID", HttpUtility.UrlEncode("00-00-00-00-00-4A", Encoding.UTF8));
                requestParams.AppendFormat("&{0}={1}", "GameType", server.GameID);
                requestParams.AppendFormat("&{0}={1}", "ServerID", server.ID);
                requestParams.AppendFormat("&{0}={1}", "RetailID", "0000");
                requestParams.AppendFormat("&{0}={1}", "RetailUser", "");

                string  errorInfo = string.Empty;
                Message msg       = new Message();
                using (MessageReader msgReader = MessageReader.Create(server.BaseUrl, requestParams.ToString(), msg))
                {
                    if (msgReader == null)
                    {
                        return;
                    }

                    if (msg.ErrorCode != 0)
                    {
                        errorInfo = string.Format("游戏登录监视>>{0}[{4}服-{1}]登录出错,Error:{2}-{3}", server.GameName, server.Name, msg.ErrorCode, msg.ErrorInfo, server.ID);
                        Logger.SaveLog(new Exception(errorInfo));


                        //Modify post trace
                        string planName  = string.Format("监视游戏:{0},服:{1}登录失败", server.GameName, server.Name);
                        string planValue = string.Format("{0}:{1}", msg.ErrorCode, msg.ErrorInfo);
                        OaSimplePlanHelper.PostDataToServer(planName, planValue);
                    }
                    else
                    {
                        Logger.SaveLog(string.Format("Game login surveillance >> {0} {2} dress - {1}] successful login", server.GameName, server.Name, server.ID));
                    }
                }

                if (!string.IsNullOrEmpty(errorInfo))
                {
                    SendToMail(errorInfo);
                }
            }
        }
예제 #4
0
        private static string PostGameServer(string contractId, int slnId, string serverUrl, string requestParams, out string sid, out string uid)
        {
            sid = "";
            uid = "";
            StringBuilder respContent = new StringBuilder();
            Message       msg         = new Message();
            MessageReader msgReader   = MessageReader.Create(serverUrl, requestParams, ref msg, IsSocket);

            if (msgReader != null)
            {
                try
                {
                    ProcessResult(contractId, slnId, respContent, msg, msgReader, out sid, out uid);
                }
                finally
                {
                    msgReader.Dispose();
                }
            }
            return(respContent.ToString());
        }
예제 #5
0
        protected void btnTest_Click(object sender, EventArgs e)
        {
            int     contractID = int.Parse(ddlContract.Text);
            Message msg        = new Message();

            string requestParams = GetRequestParams("", "0", contractID, SlnID, txtVersion.Text);
            //StringBuilder requestParams = new StringBuilder();
            //requestParams.AppendFormat("Sid={0}&Uid={1}&ActionID={2}&ClientVersion={3}&rl=1", string.Empty, string.Empty, contractID, txtVersion.Text);
            string serverUrl = txtServerUrl.Text;

            string[] keyNames = txtKeyName.Text.Split(new char[] { ',' });

            MessageReader msgReader = MessageReader.Create(serverUrl, requestParams, ref msg, false);

            if (msgReader != null)
            {
                try
                {
                    if (msg.ErrorCode != 0)
                    {
                        txtResponse.Text = msg.ErrorInfo;
                    }
                    else
                    {
                        txtResponse.Text = new ParamInfoBLL().LuaConfig(SlnID, contractID, keyNames, msgReader);
                    }
                }
                catch (Exception ex)
                {
                    txtResponse.Text = ex.ToString();
                }
                finally
                {
                    msgReader.Dispose();
                }
            }
        }
예제 #6
0
        static int Main(string[] args)
        {
            var version = Environment.Version;

            Log.InfoFormat("start at current directory {0}", Directory.GetCurrentDirectory());
            Log.Info("parsing command args");

            if (!ParseCommandLine(args))
            {
                Log.Error("command line parse error");
                return(0);
            }
            Log.InfoFormat("Starting plugin, settings:{0}", parametres);

            Log.InfoFormat("Statring cef runtime");

            if (!CefRintimePrepare(args, temporaryDirectoryPath))
            {
                Log.Error("cef runtime initialisation failed");
                return(0); //immediate exit
            }


            try {
                Log.Info("starting cef worker");
                var worker = new CefWorker(parametres.SharedFileName);
                worker.Init(parametres);
                Log.Info("Binding shared memory");
                SharedTextureWriter server = new SharedTextureWriter(parametres.SharedFileName, parametres.TextureSize);
                MessageReader       inSrv  = MessageReader.Create(parametres.inCommFile, 10000);
                MessageWriter       outSrv = MessageWriter.Create(parametres.outCommFile, 10000);
                Log.Info("complete to bind shared memory, ready and wait");
                var app = new App(worker, server, inSrv, outSrv, false);
                Log.Info("Enter main loop");
                try {
                    while (app.IsRunning)
                    {
                        Application.DoEvents();
                        app.CheckMessage();     //check incoming messages
                    }
                }
                catch (Exception e) {
                    Log.ErrorFormat("abnormal exit main loop{0}", e.Message);
                }

                Log.Info("Exit main loop END DISPOSING ALL");
                worker.Dispose();
                server.Dispose();
                inSrv.Dispose();
                outSrv.Dispose();
            }
            catch (Exception e) {
                Log.ErrorFormat("Unclean exit error {0}", e.Message);
            }
            GC.Collect();
            GC.WaitForFullGCComplete(-1);
            Log.Info("CefRuntime.Shutdown");
            CefRuntime.Shutdown();
            Log.Info("Final exit");
            return(0);
        }