public void Main() { try { int counter = 0; DateTime before = DateTime.Now; while (Xbox.Ping(500)) { try { if (!mnuPause.Checked && Video.IsActive) { //ParseUserInput(); // dont bother updating at full speed if minimized, just poll so we don't lose the stream... if (this.WindowState == FormWindowState.Minimized) { System.Threading.Thread.Sleep(1000); } renderWindow.Image = Video.NextFrame(); status.Text = "Frame: " + Video.FrameNumber; // Xbox.GetUInt32(Xbox.GetUInt32(0xB0033DA0)); (presentation frame number) counter++; } // attempt to recreate videostream before breaking out of the loop // the main reason for it becoming inactive is if its paused for more than 5 seconds or so... if (!Video.IsActive && !Video.Restart()) { break; } } catch (Exception) { Xbox.Connect(); Video.Restart(); } Application.DoEvents(); } TimeSpan elapse = DateTime.Now - before; double fps = counter / elapse.TotalSeconds; Xbox.Disconnect(); renderWindow.Image = null; mnuPause.Checked = false; mnuStep.Enabled = false; status.Text = "Disconnected"; } catch (Exception) { } renderWindow.Image = GetDefaultImage(); }
private static void EnterRDCP(Xbox xbox) { //Get input string input = string.Empty; xbox.Connect(); //Loop do { Console.Write("{0}>", xbox.Name); input = Console.ReadLine(); string[] cmd = GetCommand(input); if (input == ".") { } else if (cmd.Length > 0 && cmd[0].ToUpper() != "BYE") { xbox.SendCommand(cmd[0], cmd.Where((c, i) => i > 0).ToArray()); Thread.Sleep(5); xbox.GetResponse(); } else { break; //If user types bye command exit the loop and disconnect } }while (true); //Disconnect xbox.Disconnect(); }
/// <summary> /// Initializes a new instance of the <see cref="RemoteItemObject"/> class using the specified debug Xbox and items. /// </summary> /// <param name="xbox">The remote debug Xbox.</param> /// <param name="remoteItems">The remote items.</param> public RemoteItemObject(Xbox xbox, params ItemInformation[] remoteItems) { //Setup xboxAddress = (xbox ?? throw new ArgumentNullException(nameof(xbox))).RemoteEndPoint.Address; List <ItemObject> items = new List <ItemObject>(); //Connect xbox.Connect(); //Set items if (remoteItems != null && remoteItems.Length > 0) { //Add files foreach (var file in remoteItems.Where(i => !i.Attributes.HasFlag(FileAttributes.Directory))) { items.Add(new ItemObject() { Attributes = (uint)file.Attributes, Created = file.Created, Directory = file.Directory, Modified = file.Modified, Name = file.Name, Size = file.Size, }); } //Discover files in directories foreach (var directory in remoteItems.Where(i => i.Attributes.HasFlag(FileAttributes.Directory))) { //Get items var tempItems = DiscoverObjects(xbox, Path.Combine(directory.Directory, directory.Name)); //Localize for (int i = 0; i < tempItems.Length; i++) { tempItems[i].Name = Path.Combine(tempItems[i].Directory, tempItems[i].Name); tempItems[i].Name = tempItems[i].Name.Replace(directory.Directory, string.Empty); tempItems[i].Directory = directory.Directory; } //Add items.AddRange(tempItems); } //Set this.items = items.ToArray(); } //Disconnect xbox.Disconnect(); }
/// <summary> /// De-I/nitializes Real Time Halo. /// </summary> /// <remarks></remarks> public static void DeInitRTH() { switch (connectedDebugType) { case debugType.RthDLL: DeInitRTHExtern(); _IsConnected = false; break; case debugType.YeloDebug: xboxDebug.Disconnect(); _IsConnected = false; break; } }
public void ConnectionTest() { _xbox.Connect(AssemblyGlobals.TestXbox.Ip); _xbox.Disconnect(); // subsequent connections should reconnect for (int i = 0; i < 5; i++) { _xbox.Connect(AssemblyGlobals.TestXbox.Ip); } for (int i = 0; i < 5; i++) { _xbox.Reconnect(); } }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); if (Video != null) { Video.End(); } if (Xbox != null) { Xbox.Disconnect(); } }
private MemoryStream GetFileContents(ItemObject[] items, int index) { //Prepare MemoryStream ms = null; //Check if (items != null && index < items.Length) { //Prepare ms = new MemoryStream(); ItemObject item = items[index]; //Setup byte[] buffer = new byte[item.Size]; //Find xbox Xbox xbox = NameAnsweringProtocol.Discover(xboxAddress); try { //Connect xbox.Connect(); //Download if (!xbox.GetData(Path.Combine(item.Directory, item.Name), ref buffer)) { buffer = new byte[1]; } //Disconnect xbox.Disconnect(); } catch { buffer = new byte[1]; } //Check if (buffer.Length == 0) { buffer = new byte[1]; } ms.Write(buffer, 0, buffer.Length); } //Return return(ms); }
static void WatchHalo2() { Xbox notifer = new Xbox(); notifer.ConnectToIP(XBox.DebugIP.ToString()); notifer.EnableNotificationSession = true; notifer.RegisterNotificationSession(); while (MainThreadRunning) { notifer.ReceiveNotifications(); foreach (string note in notifer.Notifications) { if (note == "Test") { bool test = true; } } notifer.Notifications.Clear(); } notifer.Disconnect(); }
public FileUploadDialog(Xbox xbox, string destinationDirectoryName, params LocalObject[] objects) : this() { //Setup Xbox = xbox ?? throw new ArgumentNullException(nameof(xbox)); m_LocalObjects = objects ?? throw new ArgumentNullException(nameof(objects)); m_DestinationDirectoryName = destinationDirectoryName; //Connect xbox.Connect(); //Loop foreach (LocalObject localObject in objects.Where(o => o.IsDirectory)) { foreach (string directory in localObject.NestedDirectories) { //Get info DirectoryInfo info = new DirectoryInfo(directory); string targetPath = GetRemoteName(m_DestinationDirectoryName, localObject.Root, directory); //Make directory if (xbox.MakeDirectory(targetPath)) { xbox.SetAttributes(targetPath, info.CreationTime, info.LastWriteTime, info.Attributes); } } } //Disconnect xbox.Disconnect(); //Get file count m_FileCount = objects.Count(o => o.IsFile) + objects.SelectMany(o => o.NestedFiles).Count(); //Setup xbox.UploadFileCompleted += Xbox_UploadFileCompleted; xbox.UploadProgressChanged += Xbox_UploadProgressChanged; }