Volt_Cruelerz

URLD

Mar 16th, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1. package URLDownloader {
  2.     function Gui::initialize() {
  3.         parent::initialize();
  4.         $LineNumber=0;
  5.         $Line=0;
  6.         $DownLines[0]=0;
  7.        
  8.         // Create the HTTPObject
  9.         %feed = new HTTPObject(ServerList);
  10.         // Define a dynamic field to store the last connection state
  11.         %feed.lastState = "None";
  12.         echo(%this.lastState);
  13.         // Send the GET command
  14.         //%feed.get("www.google.com:80", "/ig/api", "weather=Las-Vegas,US");
  15.         %feed.get("www.dropbox.com:80", "/u/12299034/LTSServerList.txt");
  16.     }
  17. };
  18. activatePackage(URLDownloader);
  19.  
  20. function ServerList::onDNSFailed(%this)
  21. {
  22.     // Store this state
  23.     %this.lastState = "DNSFailed";
  24.     echo(%this.lastState);
  25.     // Handle DNS failure
  26. }
  27.  
  28. function ServerList::onConnectFailed(%this)
  29. {
  30.     // Store this state
  31.     %this.lastState = "ConnectFailed";
  32.     echo(%this.lastState);
  33.     // Handle connection failure
  34. }
  35.  
  36. function ServerList::onDNSResolved(%this)
  37. {
  38.     // Store this state
  39.     %this.lastState = "DNSResolved";
  40.     echo(%this.lastState);
  41. }
  42.  
  43. function ServerList::onConnected(%this)
  44. {
  45.     // Store this state
  46.     %this.lastState = "Connected";
  47.     echo(%this.lastState);
  48.     // Clear our buffer
  49.     %this.buffer = "";
  50. }
  51.  
  52. function ServerList::onDisconnect(%this)
  53. {
  54.     // Store this state
  55.     echo("Disconnected");
  56.     %this.lastState = "Disconnected";
  57.     echo(%this.lastState);
  58.     // Output the buffer to the console
  59.     echo("Server File Contents:");
  60.     echo(%this.buffer);
  61.     echo("-----------------------");
  62.     for(%i=1;%i<$DownLines[$Line];%i++)
  63.         echo($DownLines[%i]);
  64. }
  65.  
  66. // Handle a line from the server
  67. function ServerList::onLine(%this, %line)
  68. {
  69.     // Store this line in out buffer
  70.     echo("Receiving Data from Server");
  71.     $DownLines[$Line]=%line;
  72.     echo("Line: " @ %line);
  73.     $Line++;
  74.     %this.buffer = %this.buffer @ %line;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment