Util.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Data;
  29. using System.IO;
  30. using System.IO.Compression;
  31. using System.Net;
  32. using System.Net.Sockets;
  33. using System.Reflection;
  34. using System.Runtime.Serialization;
  35. using System.Runtime.Serialization.Formatters.Binary;
  36. using System.Security.Cryptography;
  37. using System.Text;
  38. using System.Text.RegularExpressions;
  39. using System.Xml;
  40. using libsecondlife;
  41. using log4net;
  42. using Nini.Config;
  43. using Nwc.XmlRpc;
  44. namespace OpenSim.Framework
  45. {
  46. /// <summary>
  47. /// Miscellaneous utility functions
  48. /// </summary>
  49. public class Util
  50. {
  51. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  52. private static uint nextXferID = 5000;
  53. private static Random randomClass = new Random();
  54. // Get a list of invalid file characters (OS dependent)
  55. private static string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]";
  56. private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]";
  57. private static object XferLock = new object();
  58. #region Vector Equations
  59. /// <summary>
  60. /// Get the distance between two 3d vectors
  61. /// </summary>
  62. /// <param name="a">A 3d vector</param>
  63. /// <param name="b">A 3d vector</param>
  64. /// <returns>The distance between the two vectors</returns>
  65. public static double GetDistanceTo(LLVector3 a, LLVector3 b)
  66. {
  67. float dx = a.X - b.X;
  68. float dy = a.Y - b.Y;
  69. float dz = a.Z - b.Z;
  70. return Math.Sqrt(dx * dx + dy * dy + dz * dz);
  71. }
  72. /// <summary>
  73. /// Get the magnitude of a 3d vector
  74. /// </summary>
  75. /// <param name="a">A 3d vector</param>
  76. /// <returns>The magnitude of the vector</returns>
  77. public static double GetMagnitude(LLVector3 a)
  78. {
  79. return Math.Sqrt((a.X * a.X) + (a.Y * a.Y) + (a.Z * a.Z));
  80. }
  81. /// <summary>
  82. /// Get a normalized form of a 3d vector
  83. /// </summary>
  84. /// <param name="a">A 3d vector</param>
  85. /// <returns>A new vector which is normalized form of the vector</returns>
  86. /// <remarks>The vector paramater cannot be <0,0,0></remarks>
  87. public static LLVector3 GetNormalizedVector(LLVector3 a)
  88. {
  89. if (IsZeroVector(a))
  90. throw new ArgumentException("Vector paramater cannot be a zero vector.");
  91. float Mag = (float) GetMagnitude(a);
  92. return new LLVector3(a.X / Mag, a.Y / Mag, a.Z / Mag);
  93. }
  94. /// <summary>
  95. /// Returns if a vector is a zero vector (has all zero components)
  96. /// </summary>
  97. /// <returns></returns>
  98. public static bool IsZeroVector(LLVector3 v)
  99. {
  100. if (v.X == 0 && v.Y == 0 && v.Z == 0)
  101. {
  102. return true;
  103. }
  104. return false;
  105. }
  106. # endregion
  107. public Util()
  108. {
  109. }
  110. public static Random RandomClass
  111. {
  112. get { return randomClass; }
  113. }
  114. public static ulong UIntsToLong(uint X, uint Y)
  115. {
  116. return Helpers.UIntsToLong(X, Y);
  117. }
  118. public static T Clamp<T>(T x, T min, T max)
  119. where T : System.IComparable<T>
  120. {
  121. return x.CompareTo(max) > 0 ? max :
  122. x.CompareTo(min) < 0 ? min :
  123. x;
  124. }
  125. public static uint GetNextXferID()
  126. {
  127. uint id = 0;
  128. lock (XferLock)
  129. {
  130. id = nextXferID;
  131. nextXferID++;
  132. }
  133. return id;
  134. }
  135. public static string GetFileName(string file)
  136. {
  137. // Return just the filename on UNIX platforms
  138. // TODO: this should be customisable with a prefix, but that's something to do later.
  139. if (Environment.OSVersion.Platform == PlatformID.Unix)
  140. {
  141. return file;
  142. }
  143. // Return %APPDATA%/OpenSim/file for 2K/XP/NT/2K3/VISTA
  144. // TODO: Switch this to System.Enviroment.SpecialFolders.ApplicationData
  145. if (Environment.OSVersion.Platform == PlatformID.Win32NT)
  146. {
  147. if (!Directory.Exists("%APPDATA%\\OpenSim\\"))
  148. {
  149. Directory.CreateDirectory("%APPDATA%\\OpenSim");
  150. }
  151. return "%APPDATA%\\OpenSim\\" + file;
  152. }
  153. // Catch all - covers older windows versions
  154. // (but those probably wont work anyway)
  155. return file;
  156. }
  157. /// <summary>
  158. /// Debug utility function to convert unbroken strings of XML into something human readable for occasional debugging purposes.
  159. ///
  160. /// Please don't delete me even if I appear currently unused!
  161. /// </summary>
  162. /// <param name="rawXml"></param>
  163. /// <returns></returns>
  164. public static string GetFormattedXml(string rawXml)
  165. {
  166. XmlDocument xd = new XmlDocument();
  167. xd.LoadXml(rawXml);
  168. StringBuilder sb = new StringBuilder();
  169. StringWriter sw = new StringWriter(sb);
  170. XmlTextWriter xtw = new XmlTextWriter(sw);
  171. xtw.Formatting = Formatting.Indented;
  172. try
  173. {
  174. xd.WriteTo(xtw);
  175. }
  176. finally
  177. {
  178. xtw.Close();
  179. }
  180. return sb.ToString();
  181. }
  182. public static bool IsEnvironmentSupported(ref string reason)
  183. {
  184. // Must have .NET 2.0 (Generics / libsl)
  185. if (Environment.Version.Major < 2)
  186. {
  187. reason = ".NET 1.0/1.1 lacks components that is used by OpenSim";
  188. return false;
  189. }
  190. // Windows 95/98/ME are unsupported
  191. if (Environment.OSVersion.Platform == PlatformID.Win32Windows &&
  192. Environment.OSVersion.Platform != PlatformID.Win32NT)
  193. {
  194. reason = "Windows 95/98/ME will not run OpenSim";
  195. return false;
  196. }
  197. // Windows 2000 / Pre-SP2 XP
  198. if (Environment.OSVersion.Version.Major == 5 &&
  199. Environment.OSVersion.Version.Minor == 0)
  200. {
  201. reason = "Please update to Windows XP Service Pack 2 or Server2003";
  202. return false;
  203. }
  204. return true;
  205. }
  206. public static int UnixTimeSinceEpoch()
  207. {
  208. return ToUnixTime(DateTime.UtcNow);
  209. }
  210. public static int ToUnixTime(DateTime stamp)
  211. {
  212. TimeSpan t = (stamp.ToUniversalTime() - Convert.ToDateTime("1/1/1970 8:00:00 AM"));
  213. return (int) t.TotalSeconds;
  214. }
  215. public static DateTime ToDateTime(ulong seconds)
  216. {
  217. DateTime epoch = Convert.ToDateTime("1/1/1970 8:00:00 AM");
  218. return epoch.AddSeconds(seconds);
  219. }
  220. public static DateTime ToDateTime(int seconds)
  221. {
  222. DateTime epoch = Convert.ToDateTime("1/1/1970 8:00:00 AM");
  223. return epoch.AddSeconds(seconds);
  224. }
  225. public static string Md5Hash(string pass)
  226. {
  227. MD5 md5 = MD5CryptoServiceProvider.Create();
  228. byte[] dataMd5 = md5.ComputeHash(Encoding.Default.GetBytes(pass));
  229. StringBuilder sb = new StringBuilder();
  230. for (int i = 0; i < dataMd5.Length; i++)
  231. sb.AppendFormat("{0:x2}", dataMd5[i]);
  232. return sb.ToString();
  233. }
  234. public static string GetRandomCapsPath()
  235. {
  236. LLUUID caps = LLUUID.Random();
  237. string capsPath = caps.ToString();
  238. capsPath = capsPath.Remove(capsPath.Length - 4, 4);
  239. return capsPath;
  240. }
  241. public static int fast_distance2d(int x, int y)
  242. {
  243. x = Math.Abs(x);
  244. y = Math.Abs(y);
  245. int min = Math.Min(x, y);
  246. return (x + y - (min >> 1) - (min >> 2) + (min >> 4));
  247. }
  248. public static string FieldToString(byte[] bytes)
  249. {
  250. return FieldToString(bytes, String.Empty);
  251. }
  252. /// <summary>
  253. /// Convert a variable length field (byte array) to a string, with a
  254. /// field name prepended to each line of the output
  255. /// </summary>
  256. /// <remarks>If the byte array has unprintable characters in it, a
  257. /// hex dump will be put in the string instead</remarks>
  258. /// <param name="bytes">The byte array to convert to a string</param>
  259. /// <param name="fieldName">A field name to prepend to each line of output</param>
  260. /// <returns>An ASCII string or a string containing a hex dump, minus
  261. /// the null terminator</returns>
  262. public static string FieldToString(byte[] bytes, string fieldName)
  263. {
  264. // Check for a common case
  265. if (bytes.Length == 0) return String.Empty;
  266. StringBuilder output = new StringBuilder();
  267. bool printable = true;
  268. for (int i = 0; i < bytes.Length; ++i)
  269. {
  270. // Check if there are any unprintable characters in the array
  271. if ((bytes[i] < 0x20 || bytes[i] > 0x7E) && bytes[i] != 0x09
  272. && bytes[i] != 0x0D && bytes[i] != 0x0A && bytes[i] != 0x00)
  273. {
  274. printable = false;
  275. break;
  276. }
  277. }
  278. if (printable)
  279. {
  280. if (fieldName.Length > 0)
  281. {
  282. output.Append(fieldName);
  283. output.Append(": ");
  284. }
  285. output.Append(CleanString(UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1)));
  286. }
  287. else
  288. {
  289. for (int i = 0; i < bytes.Length; i += 16)
  290. {
  291. if (i != 0)
  292. output.Append(Environment.NewLine);
  293. if (fieldName.Length > 0)
  294. {
  295. output.Append(fieldName);
  296. output.Append(": ");
  297. }
  298. for (int j = 0; j < 16; j++)
  299. {
  300. if ((i + j) < bytes.Length)
  301. output.Append(String.Format("{0:X2} ", bytes[i + j]));
  302. else
  303. output.Append(" ");
  304. }
  305. for (int j = 0; j < 16 && (i + j) < bytes.Length; j++)
  306. {
  307. if (bytes[i + j] >= 0x20 && bytes[i + j] < 0x7E)
  308. output.Append((char) bytes[i + j]);
  309. else
  310. output.Append(".");
  311. }
  312. }
  313. }
  314. return output.ToString();
  315. }
  316. /// <summary>
  317. /// Returns a IP address from a specified DNS, favouring IPv4 addresses.
  318. /// </summary>
  319. /// <param name="dnsAddress">DNS Hostname</param>
  320. /// <returns>An IP address, or null</returns>
  321. public static IPAddress GetHostFromDNS(string dnsAddress)
  322. {
  323. // Is it already a valid IP? No need to look it up.
  324. IPAddress ipa;
  325. if (IPAddress.TryParse(dnsAddress, out ipa))
  326. return ipa;
  327. IPAddress[] hosts = null;
  328. // Not an IP, lookup required
  329. try
  330. {
  331. hosts = Dns.GetHostEntry(dnsAddress).AddressList;
  332. }
  333. catch (Exception e)
  334. {
  335. m_log.ErrorFormat("[UTIL]: An error occurred while resolving {0}, {1}", dnsAddress, e);
  336. // Still going to throw the exception on for now, since this was what was happening in the first place
  337. throw e;
  338. }
  339. foreach (IPAddress host in hosts)
  340. {
  341. if (host.AddressFamily == AddressFamily.InterNetwork)
  342. {
  343. return host;
  344. }
  345. }
  346. if (hosts.Length > 0)
  347. return hosts[0];
  348. return null;
  349. }
  350. public static IPAddress GetLocalHost()
  351. {
  352. string dnsAddress = "localhost";
  353. IPAddress[] hosts = Dns.GetHostEntry(dnsAddress).AddressList;
  354. foreach (IPAddress host in hosts)
  355. {
  356. if (!IPAddress.IsLoopback(host) && host.AddressFamily == AddressFamily.InterNetwork)
  357. {
  358. return host;
  359. }
  360. }
  361. if (hosts.Length > 0)
  362. return hosts[0];
  363. return null;
  364. }
  365. /// <summary>
  366. /// Removes all invalid path chars (OS dependent)
  367. /// </summary>
  368. /// <param name="path">path</param>
  369. /// <returns>safe path</returns>
  370. public static string safePath(string path)
  371. {
  372. return Regex.Replace(path, @regexInvalidPathChars, string.Empty);
  373. }
  374. /// <summary>
  375. /// Removes all invalid filename chars (OS dependent)
  376. /// </summary>
  377. /// <param name="path">filename</param>
  378. /// <returns>safe filename</returns>
  379. public static string safeFileName(string filename)
  380. {
  381. return Regex.Replace(filename, @regexInvalidFileChars, string.Empty);
  382. ;
  383. }
  384. //
  385. // directory locations
  386. //
  387. public static string homeDir()
  388. {
  389. string temp;
  390. // string personal=(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
  391. // temp = Path.Combine(personal,".OpenSim");
  392. temp = ".";
  393. return temp;
  394. }
  395. public static string assetsDir()
  396. {
  397. return Path.Combine(configDir(), "assets");
  398. }
  399. public static string inventoryDir()
  400. {
  401. return Path.Combine(configDir(), "inventory");
  402. }
  403. public static string configDir()
  404. {
  405. return ".";
  406. }
  407. public static string dataDir()
  408. {
  409. return ".";
  410. }
  411. public static string logDir()
  412. {
  413. return ".";
  414. }
  415. // Nini (config) related Methods
  416. public static IConfigSource ConvertDataRowToXMLConfig(DataRow row, string fileName)
  417. {
  418. if (!File.Exists(fileName))
  419. {
  420. //create new file
  421. }
  422. XmlConfigSource config = new XmlConfigSource(fileName);
  423. AddDataRowToConfig(config, row);
  424. config.Save();
  425. return config;
  426. }
  427. public static void AddDataRowToConfig(IConfigSource config, DataRow row)
  428. {
  429. config.Configs.Add((string) row[0]);
  430. for (int i = 0; i < row.Table.Columns.Count; i++)
  431. {
  432. config.Configs[(string) row[0]].Set(row.Table.Columns[i].ColumnName, row[i]);
  433. }
  434. }
  435. public static float Clip(float x, float min, float max)
  436. {
  437. return Math.Min(Math.Max(x, min), max);
  438. }
  439. public static int Clip(int x, int min, int max)
  440. {
  441. return Math.Min(Math.Max(x, min), max);
  442. }
  443. /// <summary>
  444. /// Convert an LLUUID to a raw uuid string. Right now this is a string without hyphens.
  445. /// </summary>
  446. /// <param name="lluuid"></param>
  447. /// <returns></returns>
  448. public static String ToRawUuidString(LLUUID lluuid)
  449. {
  450. return lluuid.UUID.ToString("n");
  451. }
  452. public static string CleanString(string input)
  453. {
  454. if (input.Length == 0)
  455. return input;
  456. int clip = input.Length;
  457. // Test for ++ string terminator
  458. int pos = input.IndexOf("\0");
  459. if (pos != -1 && pos < clip)
  460. clip = pos;
  461. // Test for CR
  462. pos = input.IndexOf("\r");
  463. if (pos != -1 && pos < clip)
  464. clip = pos;
  465. // Test for LF
  466. pos = input.IndexOf("\n");
  467. if (pos != -1 && pos < clip)
  468. clip = pos;
  469. // Truncate string before first end-of-line character found
  470. return input.Substring(0, clip);
  471. }
  472. /// <summary>
  473. /// returns the contents of /etc/issue on Unix Systems
  474. /// Use this for where it's absolutely necessary to implement platform specific stuff
  475. /// </summary>
  476. /// <returns></returns>
  477. public static string ReadEtcIssue()
  478. {
  479. try
  480. {
  481. StreamReader sr = new StreamReader("/etc/issue.net");
  482. string issue = sr.ReadToEnd();
  483. sr.Close();
  484. return issue;
  485. }
  486. catch (Exception)
  487. {
  488. return "";
  489. }
  490. }
  491. public static void SerializeToFile(string filename, Object obj)
  492. {
  493. IFormatter formatter = new BinaryFormatter();
  494. Stream stream = null;
  495. try
  496. {
  497. stream = new FileStream(
  498. filename, FileMode.Create,
  499. FileAccess.Write, FileShare.None);
  500. formatter.Serialize(stream, obj);
  501. }
  502. catch (Exception e)
  503. {
  504. System.Console.WriteLine(e.Message);
  505. System.Console.WriteLine(e.StackTrace);
  506. }
  507. finally
  508. {
  509. if (stream != null)
  510. {
  511. stream.Close();
  512. }
  513. }
  514. }
  515. public static Object DeserializeFromFile(string filename)
  516. {
  517. IFormatter formatter = new BinaryFormatter();
  518. Stream stream = null;
  519. Object ret = null;
  520. try
  521. {
  522. stream = new FileStream(
  523. filename, FileMode.Open,
  524. FileAccess.Read, FileShare.None);
  525. ret = formatter.Deserialize(stream);
  526. }
  527. catch (Exception e)
  528. {
  529. System.Console.WriteLine(e.Message);
  530. System.Console.WriteLine(e.StackTrace);
  531. }
  532. finally
  533. {
  534. if (stream != null)
  535. {
  536. stream.Close();
  537. }
  538. }
  539. return ret;
  540. }
  541. public static string Compress(string text)
  542. {
  543. byte[] buffer = Encoding.UTF8.GetBytes(text);
  544. MemoryStream memory = new MemoryStream();
  545. using (GZipStream compressor = new GZipStream(memory, CompressionMode.Compress, true))
  546. {
  547. compressor.Write(buffer, 0, buffer.Length);
  548. }
  549. memory.Position = 0;
  550. // MemoryStream outStream = new MemoryStream();
  551. byte[] compressed = new byte[memory.Length];
  552. memory.Read(compressed, 0, compressed.Length);
  553. byte[] compressedBuffer = new byte[compressed.Length + 4];
  554. System.Buffer.BlockCopy(compressed, 0, compressedBuffer, 4, compressed.Length);
  555. System.Buffer.BlockCopy(BitConverter.GetBytes(buffer.Length), 0, compressedBuffer, 0, 4);
  556. return Convert.ToBase64String(compressedBuffer);
  557. }
  558. public static string Decompress(string compressedText)
  559. {
  560. byte[] compressedBuffer = Convert.FromBase64String(compressedText);
  561. using (MemoryStream memory = new MemoryStream())
  562. {
  563. int msgLength = BitConverter.ToInt32(compressedBuffer, 0);
  564. memory.Write(compressedBuffer, 4, compressedBuffer.Length - 4);
  565. byte[] buffer = new byte[msgLength];
  566. memory.Position = 0;
  567. using (GZipStream decompressor = new GZipStream(memory, CompressionMode.Decompress))
  568. {
  569. decompressor.Read(buffer, 0, buffer.Length);
  570. }
  571. return Encoding.UTF8.GetString(buffer);
  572. }
  573. }
  574. public static string[] ParseStartLocationRequest(string startLocationRequest)
  575. {
  576. string[] returnstring = new string[4];
  577. // format uri:RegionName&X&Y&Z
  578. returnstring[0] = "last";
  579. returnstring[1] = "127";
  580. returnstring[2] = "127";
  581. returnstring[3] = "0";
  582. // This is the crappy way of doing it.
  583. if (startLocationRequest.Contains(":") && startLocationRequest.Contains("&"))
  584. {
  585. //System.Console.WriteLine("StartLocationRequest Contains proper elements");
  586. string[] splitstr = startLocationRequest.Split(':'); //,2,StringSplitOptions.RemoveEmptyEntries);
  587. //System.Console.WriteLine("Found " + splitstr.GetLength(0) + " elements in 1st split result");
  588. if (splitstr.GetLength(0) == 2)
  589. {
  590. string[] splitstr2 = splitstr[1].Split('&'); //, 4, StringSplitOptions.RemoveEmptyEntries);
  591. //System.Console.WriteLine("Found " + splitstr2.GetLength(0) + " elements in 2nd split result");
  592. int len = Math.Min(splitstr2.GetLength(0), 4);
  593. for (int i = 0; i < 4; ++i)
  594. {
  595. if (len > i)
  596. {
  597. returnstring[i] = splitstr2[i];
  598. }
  599. }
  600. }
  601. }
  602. return returnstring;
  603. }
  604. public static XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args)
  605. {
  606. return SendXmlRpcCommand(url, methodName, args);
  607. }
  608. public static XmlRpcResponse SendXmlRpcCommand(string url, string methodName, object[] args)
  609. {
  610. XmlRpcRequest client = new XmlRpcRequest(methodName, args);
  611. return client.Send(url, 6000);
  612. }
  613. }
  614. }