internal ListenManager(ClientEngine engine) { Engine = engine; Listeners = new MonoTorrentCollection<PeerListener>(); _endCheckEncryptionCallback = ClientEngine.MainLoop.Wrap(EndCheckEncryption); _handshakeReceivedCallback = (a, b, c) => ClientEngine.MainLoop.Queue(() => OnPeerHandshakeReceived(a, b, c)); }
public CriticalExceptionEventArgs(Exception ex, ClientEngine engine) { if (ex == null) throw new ArgumentNullException(nameof(ex)); if (engine == null) throw new ArgumentNullException(nameof(engine)); Engine = engine; Exception = ex; }
void WebSocket_Error(object sender, ClientEngine.ErrorEventArgs e) { if (e.Exception != null) { if (e.Exception is SocketException && ((SocketException)e.Exception).ErrorCode == (int)SocketError.AccessDenied) ErrorMessage = (new SocketException((int)SocketError.ConnectionRefused)).Message; else ErrorMessage = e.Exception.StackTrace; if (m_WebSocket.State == WebSocketState.None && State == NodeState.Connecting) { State = NodeState.Offline; OnDisconnected(); } } }
static void InitMonoTorrent () { queue = new ArrayList (); engine_settings = new EngineSettings (config.DownloadDir, config.ListenPort); torrent_settings = new TorrentSettings (config.UploadSlots, config.MaxConnections, (int) config.UploadSpeed, (int) config.DownloadSpeed); engine = new ClientEngine (engine_settings); // Our store torrent_list = new TorrentList (); foreach (TorrentDesc td in config.Torrents){ if (File.Exists (td.Filename)){ torrent_list.Add (td.Filename); } } }
public EngineTestRig(string savePath, int piecelength = 256*1024, PieceWriter writer = null) { if (writer == null) writer = new MemoryWriter(new NullWriter()); _listener = new CustomListener(); _engine = new ClientEngine(new EngineSettings(), _listener, writer); _torrentDict = CreateTorrent(piecelength); _torrent = Torrent.Load(_torrentDict); _manager = new TorrentManager(_torrent, savePath, new TorrentSettings()); _engine.Register(_manager); //manager.Start(); }
private void MainForm_Load( object sender, EventArgs e ) { ClassEditControl scout = new ClassEditControl( "Scout" ); scout.ClassImage = Properties.Resources.scout; // heavy ClassEditControl heavy = new ClassEditControl( "Heavy" ); heavy.ClassImage = Properties.Resources.heavy; // medic ClassEditControl medic = new ClassEditControl( "Medic" ); medic.ClassImage = Properties.Resources.medic; // soldier ClassEditControl soldier = new ClassEditControl( "Soldier" ); soldier.ClassImage = Properties.Resources.soldier; // engi ClassEditControl engineer = new ClassEditControl( "Engineer" ); engineer.ClassImage = Properties.Resources.engineer; // spy ClassEditControl spy = new ClassEditControl( "Spy" ); spy.ClassImage = Properties.Resources.spy; // sniper ClassEditControl sniper = new ClassEditControl( "Sniper" ); sniper.ClassImage = Properties.Resources.sniper; // demo ClassEditControl demo = new ClassEditControl( "Demoman" ); demo.ClassImage = Properties.Resources.demoman; // pyro ClassEditControl pyro = new ClassEditControl( "Pyro" ); pyro.ClassImage = Properties.Resources.pyro; flowLayoutPanel1.Controls.Add( scout ); flowLayoutPanel1.Controls.Add( heavy ); flowLayoutPanel1.Controls.Add( medic ); flowLayoutPanel1.Controls.Add( soldier ); flowLayoutPanel1.Controls.Add( engineer ); flowLayoutPanel1.Controls.Add( spy ); flowLayoutPanel1.Controls.Add( sniper ); flowLayoutPanel1.Controls.Add( demo ); flowLayoutPanel1.Controls.Add( pyro ); toolStripStatusLabel1.Text = "Initializing steamworks..."; try { int error; client = ( SteamClient008 )Steamworks.CreateInterface( SteamClient008.InterfaceVersion, out error ); if ( client == null ) throw new InvalidOperationException( "Unable to create ISteamClient." ); pipe = client.CreateSteamPipe(); if ( pipe == SteamPipeHandle.InvalidHandle ) throw new InvalidOperationException( "Unable to create steam pipe." ); user = client.ConnectToGlobalUser( pipe ); clientEngine = ( ClientEngine )Steamworks.CreateInterface( ClientEngine.InterfaceVersion, out error ); if ( clientEngine == null ) throw new InvalidOperationException( "Unable to create IClientEngine." ); } catch (Exception ex) { MessageBox.Show( this, "Unable to initialize steamworks. Please ensure the following:\n\n" + " * steamclient.dll, tier0_s.dll, vstdlib_s.dll, are present in the running directory\n" + " * You are logged into steam and are online.\n\nAdditional Details: " + ex.Message, "TF2 Stats Suite" ); this.Close(); return; } toolStripStatusLabel1.Text = "Loading stats..."; statsAcc = new StatsAccessor( client, pipe, user, 440 ); steamUser = ( SteamUser012 )client.GetISteamUser( user, pipe, SteamUser012.InterfaceVersion ); clientUtils = ( ClientUtils )clientEngine.GetIClientUtils( pipe, ClientUtils.InterfaceVersion ); clientUtils.SetAppIDForCurrentPipe( new AppID( 440 ) ); foreach ( ClassEditControl cec in flowLayoutPanel1.Controls ) { toolStripStatusLabel1.Text = "Loading stats for '" + cec.Class + "'..."; cec.LoadStats( statsAcc ); Application.DoEvents(); } toolStripStatusLabel1.Text = "Stats fully loaded!"; }
public LocalPeerListener(ClientEngine engine) : base(new IPEndPoint(IPAddress.Any, 6771)) { _engine = engine; }
public MainWindow(string tp, string dp, string ep, StatusIcon si) : base(Gtk.WindowType.Toplevel) { Build (); this.tp = tp; this.dp = dp; this.si = si; this.ep = ep; dhtpath = ep+ "/dht.data"; fastResumePath = ep+"/FastResume.Data"; EngineSettings es = new EngineSettings (); es.PreferEncryption = false; es.AllowedEncryption = EncryptionTypes.All; managers = new List<TorrentManager>(); engine = new MonoTorrent.Client.ClientEngine (es); engine.StatsUpdate += UpdateAll; nodeview2.NodeStore = new NodeStore (typeof(TorrentInfoRow)); nodeview2.AppendColumn ("Status", new Gtk.CellRendererText (), "text", 0); nodeview2.AppendColumn ("Progress", new CellRendererProgressBar(), "value", 4); nodeview2.AppendColumn ("Ds" + "(КБ/с)", new Gtk.CellRendererText (), "text", 2); nodeview2.AppendColumn ("Us" + "(КБ/с)", new Gtk.CellRendererText (), "text", 3); nodeview2.AppendColumn ("Seeds", new Gtk.CellRendererText (), "text", 5); jBox = new Gtk.Menu (); Gtk.MenuItem MenuItem1 = new MenuItem ("Запустить"); MenuItem1.ButtonReleaseEvent += HandleMenuItem1ButtonReleaseEvent; jBox.Add (MenuItem1); Gtk.MenuItem MenuItem4 = new MenuItem ("Пауза"); MenuItem4.ButtonReleaseEvent += HandleMenuItem4ButtonReleaseEvent; Gtk.MenuItem MenuItem2 = new MenuItem ("Остановить"); MenuItem2.ButtonReleaseEvent += HandleMenuItem2ButtonReleaseEvent; jBox.Add (MenuItem2); Gtk.MenuItem MenuItem5 = new MenuItem ("Открыть Папку..."); MenuItem5.ButtonReleaseEvent += HandleMenuItem5ButtonReleaseEvent; jBox.Add (MenuItem5); MenuItem3 = new MenuItem ("Открыть Файл"); MenuItem3.Sensitive = false; MenuItem3.ButtonReleaseEvent += HandleMenuItem3ButtonReleaseEvent; jBox.Add (MenuItem3); Gtk.MenuItem MenuItem6 = new MenuItem ("Удалить торрент"); MenuItem6.ButtonReleaseEvent += HandleMenuItem6ButtonReleaseEvent;; jBox.Add (MenuItem6); Gtk.MenuItem MenuItem7 = new MenuItem ("Удалить торрент и файлы"); MenuItem7.ButtonReleaseEvent += HandleMenuItem7ButtonReleaseEvent;; jBox.Add (MenuItem7); foreach (string file in Directory.GetFiles (tp)) { if (file.EndsWith (".torrent")) { try { LoadTorrent (file); } catch (Exception e) { File.WriteAllText(ep+"/Error.txt","Couldn't decode: "+file); XenoTorrent.TorrentError ts = new XenoTorrent.TorrentError (e.Message,file); ts.Show (); continue; } } } //engine.StopAll(); LoadFastResume(managers); newTorrents = new int[managers.Count]; StartDht (22334); // Working only with Gtk.Window object! (except [GLib.ConnectBeforeAttribute] attribute is defined on callback method) nodeview2.ButtonPressEvent += HandleNodeview2ButtonPressEvent; nodeview2.ShowAll (); engine.LocalPeerSearchEnabled = true; engine.StartAll (); }