Exemple #1
0
        private void btnLuaRunPath_Click(object sender, EventArgs e)
        {
            try
            {
                string host     = txtHost.Text;
                int    port     = txtPort.Text.ToInt();
                int    actionId = txtAction.Text.ToInt();
                string pwd      = txtPwd.Text.Trim();
                _token.GameType = txtGameType.Text.ToInt();
                _token.ServerID = txtServerID.Text.ToInt();
                _token.RetailID = txtRetailID.Text.Trim();
                _token.Pid      = txtPid.Text.Trim();
                _token.Pwd      = EncodePwdAndUrlEncode(pwd);
                SetConfig(host, port, actionId, _token, pwd);

                string funName = string.Format("Action{0}", actionId);
                ScutWriter.getInstance().writeHead(_token.Sid, _token.Uid.ToInt());
                ScutWriter.getInstance().writeInt32("ActionId", actionId);
                if (!LuaRuntime.GetContext().TryCall <Action <UserToken> >(funName, _token))
                {
                    _responseLog.WriteFormatLine("请求出错:The {0} function is not exist in lua file.", funName);
                }
                var sendData = ScutWriter.generatePostData();
                TcpRequest.Instance().Send(host, port, sendData, null);
                ScutWriter.resetData();
            }
            catch (Exception ex)
            {
                _responseLog.WriteFormatLine("请求出错:{0}", ex);
            }
            finally
            {
                ResponseReflesh();
            }
        }
Exemple #2
0
        public Main()
        {
            InitializeComponent();
            rtxtResponse.ReadOnly = true;
            LuaRuntime.GetContext().RegisterFunc("LogWriteLine", _responseLog, _responseLog.GetType().GetMethod("WriteLine"));
            LuaRuntime.GetContext().RegisterFunc("LogWriteTable", _responseLog, _responseLog.GetType().GetMethod("WriteTable"));
            InitConfig();
            TcpRequest.Instance().ReceiveCompleted += OnReceiveCompleted;

            _watchThread = new Thread(obj =>
            {
                var instance = obj as Main;
                while (true)
                {
                    Thread.Sleep(100);
                }
            });
        }