Advertisement
CGC_Codes

nws server

Jul 3rd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Runtime.Serialization;
  6. using System.Runtime.Serialization.Formatters.Binary;
  7. using System.IO;
  8.  
  9.  
  10. namespace NZBHags
  11. {
  12.    
  13.     public class NewsServer// : ISerializable
  14.     {
  15.         public bool isConnected { get; set; }
  16.         public string name { get; set; }
  17.         public string addr { get; set; }
  18.         public string username { get; set; }
  19.         public string password { get; set; }
  20.         public int port { get; set; }
  21.         public int connections { get; set; }
  22.         public int timeout { get; set; }
  23.         public NNTPConnection[] nntpConnections { get; set; }
  24.  
  25.         public NewsServer()
  26.         {
  27.             name = Properties.Settings.Default.servername;
  28.             addr = Properties.Settings.Default.serveraddr;
  29.             username = Properties.Settings.Default.serveruser;
  30.             password = Properties.Settings.Default.serverpass;
  31.             port = Properties.Settings.Default.serverport;
  32.             connections = Properties.Settings.Default.serverconnections;
  33.             timeout = Properties.Settings.Default.servertimeout;
  34.         }
  35.  
  36.  
  37.        
  38.         public void Save()
  39.         {
  40.             Properties.Settings.Default.servername = name;
  41.             Properties.Settings.Default.serveraddr = addr;
  42.             Properties.Settings.Default.serveruser = username;
  43.             Properties.Settings.Default.serverpass = password;
  44.             Properties.Settings.Default.serverport = port;
  45.             Properties.Settings.Default.serverconnections = connections;
  46.             Properties.Settings.Default.servertimeout = timeout;
  47.             Properties.Settings.Default.Save();
  48.         }
  49.  
  50.         public void Connect(MainGUI mainGui)
  51.         {
  52.             Logging.Instance.Log("Connecting to {0}, spawning {1} connections", name, connections);
  53.             nntpConnections = new NNTPConnection[connections];
  54.  
  55.            
  56.             for (int i = 0; i < connections; i++)
  57.             {
  58.                 nntpConnections[i] = new NNTPConnection(i, this, QueueHandler.Instance);
  59.                 nntpConnections[i].mainGui = mainGui;
  60.             }
  61.             isConnected = true;
  62.         }
  63.  
  64.         public void Disconnect()
  65.         {
  66.             Logging.Instance.Log("Disconnting from {0}", name);
  67.             if (nntpConnections != null)
  68.             {
  69.                 foreach (NNTPConnection conn in nntpConnections)
  70.                 {
  71.                     conn.Disconnect();
  72.                 }
  73.             }
  74.             isConnected = false;
  75.         }
  76.  
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement