示例#1
0
        internal static bool ExecuteGmCommand(STServerInfo server, string playerId, byte[] command, byte[] operate, bool needReturn, Action <string> reportProcess)
        {
            if (server == null)
            {
                return(false);
            }

            HttpWebRequest  request = null;
            HttpWebResponse respone = null;

            try
            {
                request                = WebRequest.Create(server.authGMHttp) as HttpWebRequest;
                request.KeepAlive      = false;
                request.Headers["svr"] = server.svrID;
                request.Headers["uid"] = playerId;
                request.Headers["cmd"] = Convert.ToBase64String(command);
                request.Headers["opt"] = Convert.ToBase64String(operate);
                request.Timeout        = 4000;

                respone = request.GetResponse() as HttpWebResponse;
                if (needReturn && reportProcess != null)
                {
                    using (StreamReader reader = new StreamReader(respone.GetResponseStream()))
                    {
                        reportProcess(reader.ReadToEnd());
                    }
                }
                return(true);
            }

            catch (Exception exception)
            {
                DatabaseAssistant.ReportException(exception);
                if (reportProcess != null)
                {
                    reportProcess(exception.Message + "\n");
                }
                return(false);
            }

            finally
            {
                if (request != null)
                {
                    request.Abort();
                }
                if (respone != null)
                {
                    respone.Close();
                }
            }
        }
 public static bool AddServerInfo(uint id, STServerInfo server)
 {
     if (dicServers.ContainsKey(id))
     {
         dicServers[id] = server;
     }
     else
     {
         dicServers.Add(id, server);
     }
     newSave();
     return(true);
 }