diff --git a/libsecondlife/ObjectManager.cs b/libsecondlife/ObjectManager.cs index ace0a609..c6fead3e 100644 --- a/libsecondlife/ObjectManager.cs +++ b/libsecondlife/ObjectManager.cs @@ -451,18 +451,6 @@ namespace libsecondlife #endregion - /// - /// If true, when a cached object check is received from the server - /// the full object info will automatically be requested. - /// - /// - public bool RequestAllObjects = false; - /// - /// Used to flag if Object updates should always be decoded, - /// even if no object event listenners/callbacks are registered. - /// - public bool AlwaysDecode = false; - /// /// Reference to the SecondLife client /// @@ -1121,7 +1109,8 @@ namespace libsecondlife /// protected void UpdateHandler(Packet packet, Simulator simulator) { - if (AlwaysDecode || OnNewPrim != null || OnNewAttachment != null || OnNewAvatar != null || OnNewFoliage != null) + if (Client.Settings.ALWAYS_DECODE_OBJECTS || OnNewPrim != null || OnNewAttachment != null || + OnNewAvatar != null || OnNewFoliage != null) { ObjectUpdatePacket update = (ObjectUpdatePacket)packet; UpdateDilation(simulator, update.RegionData.TimeDilation); @@ -1400,7 +1389,7 @@ namespace libsecondlife } } - if (AlwaysDecode || (OnNewAvatar != null)) + if (Client.Settings.ALWAYS_DECODE_OBJECTS || (OnNewAvatar != null)) { Avatar avatar = GetAvatar(simulator, block.ID, block.FullID); @@ -1557,7 +1546,7 @@ namespace libsecondlife // TODO: this really only needs to be called when this class is an instance of a subclass of this class... // Get primitive from factory, so subclasses can have a chance to have cached data updated - if (AlwaysDecode) + if (Client.Settings.ALWAYS_DECODE_OBJECTS) { LLObject obj; @@ -1598,7 +1587,8 @@ namespace libsecondlife /// protected void CompressedUpdateHandler(Packet packet, Simulator simulator) { - if (AlwaysDecode || OnNewPrim != null || OnNewAvatar != null || OnNewAttachment != null || OnNewFoliage != null) + if (Client.Settings.ALWAYS_DECODE_OBJECTS || OnNewPrim != null || OnNewAvatar != null || + OnNewAttachment != null || OnNewFoliage != null) { ObjectUpdateCompressedPacket update = (ObjectUpdateCompressedPacket)packet; Primitive prim; @@ -1859,7 +1849,7 @@ namespace libsecondlife protected void CachedUpdateHandler(Packet packet, Simulator simulator) { - if (RequestAllObjects) + if (Client.Settings.ALWAYS_REQUEST_OBJECTS) { List ids = new List(); ObjectUpdateCachedPacket update = (ObjectUpdateCachedPacket)packet; diff --git a/libsecondlife/SecondLife.cs b/libsecondlife/SecondLife.cs index 3ed8f1ce..764b7687 100644 --- a/libsecondlife/SecondLife.cs +++ b/libsecondlife/SecondLife.cs @@ -105,27 +105,6 @@ namespace libsecondlife Directory = new DirectoryManager(this); Terrain = new TerrainManager(this); Throttle = new AgentThrottle(this); - - CheckThreadPool(); - } - - /// - /// Under certain configurations or circumstances, the .NET or mono - /// frameworks don't give us enough I/O Completion Port threads to - /// handle all of the incoming network traffic from Second Life. This - /// function increases the number of worker threads and IOCP threads to - /// a safe value - /// - public void CheckThreadPool() - { - // Make sure we are running enough IOCP threads to safely handle all the requests - int workerThreads, completionPortThreads; - ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads); - if (completionPortThreads < 50) - { - Log(completionPortThreads + " IOCP threads available which may not be enough for heavy traffic", - Helpers.LogLevel.Warning); - } } /// diff --git a/libsecondlife/Settings.cs b/libsecondlife/Settings.cs index da382c5b..2584733f 100644 --- a/libsecondlife/Settings.cs +++ b/libsecondlife/Settings.cs @@ -69,7 +69,7 @@ namespace libsecondlife /// Setting this too low will cause web requests to repeatedly /// time out and retry. Too high of a setting may cause the library to /// block for a long time during network shutdown - public int CAPS_TIMEOUT = 8 * 1000; + public int CAPS_TIMEOUT = 20 * 1000; /// Number of milliseconds for xml-rpc to timeout public int LOGIN_TIMEOUT = 60 * 1000; /// Milliseconds before a packet is assumed lost and resent @@ -121,6 +121,12 @@ namespace libsecondlife /// Milliseconds to wait for a simulator info request through /// the grid interface public int MAP_REQUEST_TIMEOUT = 5 * 1000; + /// Used to flag if Object updates should always be decoded, + /// even if no object event listeners/callbacks are registered + public bool ALWAYS_DECODE_OBJECTS = false; + /// If true, when a cached object check is received from the + /// server the full object info will automatically be requested + public bool ALWAYS_REQUEST_OBJECTS = false; /// Cost of uploading an asset /// Read-only since this value is dynamically fetched at login diff --git a/libsecondlife/Simulator.cs b/libsecondlife/Simulator.cs index aa934d86..7b7bfe54 100644 --- a/libsecondlife/Simulator.cs +++ b/libsecondlife/Simulator.cs @@ -839,15 +839,6 @@ namespace libsecondlife } #endregion FireCallbacks - - int workerThreads, completionPortThreads; - ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads); - if (workerThreads == 0 || completionPortThreads == 0) - { - Client.Log(String.Format( - "Thread starvation, packets will be dropped. WorkerThreads: {0}, CompletionPortThreads: {1}", - workerThreads, completionPortThreads), Helpers.LogLevel.Error); - } } private void AckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs ea) diff --git a/libsecondlife/examples/Baker/Baker.cs b/libsecondlife/examples/Baker/Baker.cs index ba77f3a8..a59d2e73 100644 --- a/libsecondlife/examples/Baker/Baker.cs +++ b/libsecondlife/examples/Baker/Baker.cs @@ -12,17 +12,9 @@ namespace Baker [STAThread] static void Main(string[] args) { - if (args.Length != 3) - { - Console.WriteLine("Usage: [FirstName] [LastName] [password]"); - Console.WriteLine("Press any key to continue..."); - Console.ReadKey(); - return; - } - Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new frmBaker(args[0], args[1], args[2])); + Application.Run(new frmBaker()); } } } \ No newline at end of file diff --git a/libsecondlife/examples/Baker/Baker.csproj b/libsecondlife/examples/Baker/Baker.csproj index c551615f..d6347add 100644 --- a/libsecondlife/examples/Baker/Baker.csproj +++ b/libsecondlife/examples/Baker/Baker.csproj @@ -15,7 +15,7 @@ true full false - bin\Debug\ + ..\..\..\bin\ DEBUG;TRACE prompt 4 @@ -58,9 +58,9 @@ - - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - libsecondlife + + {D0DCFDCB-71FA-4343-A8D1-24D4665A94A4} + openjpegnet \ No newline at end of file diff --git a/libsecondlife/examples/Baker/frmBaker.Designer.cs b/libsecondlife/examples/Baker/frmBaker.Designer.cs index a4176636..c47847be 100644 --- a/libsecondlife/examples/Baker/frmBaker.Designer.cs +++ b/libsecondlife/examples/Baker/frmBaker.Designer.cs @@ -28,23 +28,105 @@ namespace Baker /// private void InitializeComponent() { + this.pic1 = new System.Windows.Forms.PictureBox(); + this.cmdLoadPic1 = new System.Windows.Forms.Button(); + this.pic2 = new System.Windows.Forms.PictureBox(); + this.pic3 = new System.Windows.Forms.PictureBox(); + this.cmdLoadPic2 = new System.Windows.Forms.Button(); + this.cmdLoadPic3 = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.pic1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pic2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pic3)).BeginInit(); this.SuspendLayout(); // + // pic1 + // + this.pic1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pic1.Location = new System.Drawing.Point(12, 12); + this.pic1.Name = "pic1"; + this.pic1.Size = new System.Drawing.Size(256, 256); + this.pic1.TabIndex = 0; + this.pic1.TabStop = false; + // + // cmdLoadPic1 + // + this.cmdLoadPic1.Location = new System.Drawing.Point(193, 274); + this.cmdLoadPic1.Name = "cmdLoadPic1"; + this.cmdLoadPic1.Size = new System.Drawing.Size(75, 23); + this.cmdLoadPic1.TabIndex = 1; + this.cmdLoadPic1.Text = "Load"; + this.cmdLoadPic1.UseVisualStyleBackColor = true; + this.cmdLoadPic1.Click += new System.EventHandler(this.cmdLoadPic_Click); + // + // pic2 + // + this.pic2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pic2.Location = new System.Drawing.Point(274, 12); + this.pic2.Name = "pic2"; + this.pic2.Size = new System.Drawing.Size(256, 256); + this.pic2.TabIndex = 2; + this.pic2.TabStop = false; + // + // pic3 + // + this.pic3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pic3.Location = new System.Drawing.Point(536, 12); + this.pic3.Name = "pic3"; + this.pic3.Size = new System.Drawing.Size(256, 256); + this.pic3.TabIndex = 3; + this.pic3.TabStop = false; + // + // cmdLoadPic2 + // + this.cmdLoadPic2.Location = new System.Drawing.Point(455, 274); + this.cmdLoadPic2.Name = "cmdLoadPic2"; + this.cmdLoadPic2.Size = new System.Drawing.Size(75, 23); + this.cmdLoadPic2.TabIndex = 4; + this.cmdLoadPic2.Text = "Load"; + this.cmdLoadPic2.UseVisualStyleBackColor = true; + this.cmdLoadPic2.Click += new System.EventHandler(this.cmdLoadPic_Click); + // + // cmdLoadPic3 + // + this.cmdLoadPic3.Location = new System.Drawing.Point(717, 274); + this.cmdLoadPic3.Name = "cmdLoadPic3"; + this.cmdLoadPic3.Size = new System.Drawing.Size(75, 23); + this.cmdLoadPic3.TabIndex = 5; + this.cmdLoadPic3.Text = "Load"; + this.cmdLoadPic3.UseVisualStyleBackColor = true; + this.cmdLoadPic3.Click += new System.EventHandler(this.cmdLoadPic_Click); + // // frmBaker // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(256, 256); + this.ClientSize = new System.Drawing.Size(806, 498); + this.Controls.Add(this.cmdLoadPic3); + this.Controls.Add(this.cmdLoadPic2); + this.Controls.Add(this.pic3); + this.Controls.Add(this.pic2); + this.Controls.Add(this.cmdLoadPic1); + this.Controls.Add(this.pic1); this.Name = "frmBaker"; this.Text = "Baker"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmBaker_FormClosing); this.Load += new System.EventHandler(this.frmBaker_Load); + ((System.ComponentModel.ISupportInitialize)(this.pic1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pic2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pic3)).EndInit(); this.ResumeLayout(false); } #endregion + private System.Windows.Forms.PictureBox pic1; + private System.Windows.Forms.Button cmdLoadPic1; + private System.Windows.Forms.PictureBox pic2; + private System.Windows.Forms.PictureBox pic3; + private System.Windows.Forms.Button cmdLoadPic2; + private System.Windows.Forms.Button cmdLoadPic3; + } } diff --git a/libsecondlife/examples/Baker/frmBaker.cs b/libsecondlife/examples/Baker/frmBaker.cs index 4108dbde..c5b43e50 100644 --- a/libsecondlife/examples/Baker/frmBaker.cs +++ b/libsecondlife/examples/Baker/frmBaker.cs @@ -6,86 +6,61 @@ using System.Drawing; using System.Drawing.Imaging; using System.Text; using System.Windows.Forms; -using libsecondlife; -using libsecondlife.Packets; +using System.IO; namespace Baker { public partial class frmBaker : Form { - private SecondLife Client = new SecondLife(); - //private PictureBox[,] Boxes = new PictureBox[16, 16]; - //private System.Timers.Timer UpdateTimer = new System.Timers.Timer(500); - private string FirstName, LastName, Password; - - //LLVector3 center = new LLVector3(128, 128, 40); - //LLVector3 up = new LLVector3(0, 0, 0.9999f); - //LLVector3 forward = new LLVector3(0, 0.9999f, 0); - //LLVector3 left = new LLVector3(0.9999f, 0, 0); - - public frmBaker(string firstName, string lastName, string password) + public frmBaker() { - FirstName = firstName; - LastName = lastName; - Password = password; - - // Build the picture boxes - //this.SuspendLayout(); - //for (int y = 0; y < 16; y++) - //{ - // for (int x = 0; x < 16; x++) - // { - // Boxes[x, y] = new System.Windows.Forms.PictureBox(); - // PictureBox box = Boxes[x, y]; - // ((System.ComponentModel.ISupportInitialize)(box)).BeginInit(); - // box.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - // box.Name = x + "," + y; - // box.Location = new System.Drawing.Point(x * 16, y * 16); - // box.Size = new System.Drawing.Size(16, 16); - // box.Visible = true; - // box.MouseUp += new MouseEventHandler(box_MouseUp); - // ((System.ComponentModel.ISupportInitialize)(box)).EndInit(); - - // this.Controls.Add(box); - // } - //} - //this.ResumeLayout(); - InitializeComponent(); } private void frmBaker_Load(object sender, EventArgs e) { - if (Client.Network.Login(FirstName, LastName, Password, "Baker", "jhurliman@wsu.edu")) - { - //UpdateTimer.Elapsed += new System.Timers.ElapsedEventHandler(UpdateTimer_Elapsed); - //UpdateTimer.Start(); - } - else - { - Console.WriteLine("Login failed: " + Client.Network.LoginError); - Console.ReadKey(); - this.Close(); - return; - } } - //void UpdateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) - //{ - // forward.Y += 0.2f; - // left.X += 0.2f; - - // if (forward.Y >= 1.0f) forward.Y = 0.0f; - // if (left.X >= 1.0f) left.X = 0.0f; - - // // Spin our camera in circles at the center of the sim to load all the terrain - // Client.Self.UpdateCamera(MainAvatar.AgentUpdateFlags.NONE, center, forward, left, up, - // LLQuaternion.Identity, LLQuaternion.Identity, 384.0f, false); - //} - private void frmBaker_FormClosing(object sender, FormClosingEventArgs e) { - Client.Network.Logout(); + } + + private void cmdLoadPic_Click(object sender, EventArgs e) + { + Button caller = (Button)sender; + PictureBox pic = null; + + switch (caller.Name) + { + case "cmdLoadPic1": + pic = pic1; + break; + case "cmdLoadPic2": + pic = pic2; + break; + case "cmdLoadPic3": + pic = pic3; + break; + } + + if (pic != null) + { + OpenFileDialog dialog = new OpenFileDialog(); + dialog.Filter = "JPEG2000 (*.jp2,*.j2c,*.j2k)|"; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + byte[] j2kdata = File.ReadAllBytes(dialog.FileName); + Image image = OpenJPEGNet.OpenJPEG.DecodeToImage(j2kdata); + pic.Image = image; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + } } } } \ No newline at end of file diff --git a/libsecondlife/examples/TestClient/ClientManager.cs b/libsecondlife/examples/TestClient/ClientManager.cs index 504e1c46..482ed5ea 100644 --- a/libsecondlife/examples/TestClient/ClientManager.cs +++ b/libsecondlife/examples/TestClient/ClientManager.cs @@ -39,7 +39,7 @@ namespace libsecondlife.TestClient public bool Running = true; - string contactPerson = ""; + string contactPerson = String.Empty; StartPosition startpos = new StartPosition(); /// diff --git a/libsecondlife/examples/TestClient/TestClient.cs b/libsecondlife/examples/TestClient/TestClient.cs index 8e867aec..fafb25b9 100644 --- a/libsecondlife/examples/TestClient/TestClient.cs +++ b/libsecondlife/examples/TestClient/TestClient.cs @@ -49,6 +49,7 @@ namespace libsecondlife.TestClient Settings.DEBUG = false; Settings.STORE_LAND_PATCHES = true; + Settings.ALWAYS_REQUEST_OBJECTS = true; Network.RegisterCallback(PacketType.AgentDataUpdate, new NetworkManager.PacketCallback(AgentDataUpdateHandler)); @@ -62,8 +63,6 @@ namespace libsecondlife.TestClient Network.RegisterCallback(PacketType.AvatarAppearance, new NetworkManager.PacketCallback(AvatarAppearanceHandler)); - Objects.RequestAllObjects = true; - updateTimer.Start(); } diff --git a/libsecondlife/examples/primexport/frmPrimExport.cs b/libsecondlife/examples/primexport/frmPrimExport.cs index 7e3c40ee..a1ebf761 100644 --- a/libsecondlife/examples/primexport/frmPrimExport.cs +++ b/libsecondlife/examples/primexport/frmPrimExport.cs @@ -302,7 +302,6 @@ namespace primexport // Setup the callbacks client.OnLogMessage += new SecondLife.LogCallback(client_OnLogMessage); - client.Objects.RequestAllObjects = true; client.Objects.OnNewPrim += new ObjectManager.NewPrimCallback(PrimSeen); client.Objects.OnNewAvatar += new ObjectManager.NewAvatarCallback(AvatarSeen); client.Objects.OnNewAttachment += new ObjectManager.NewAttachmentCallback(AttachmentSeen); @@ -312,6 +311,9 @@ namespace primexport client.Throttle.Land = 0; client.Throttle.Wind = 0; + // Make sure we download all objects + client.Settings.ALWAYS_REQUEST_OBJECTS = true; + grpLogin.Enabled = true; } diff --git a/openjpegnet/openjpegnet.csproj b/openjpegnet/openjpegnet.csproj index 077707d3..1f74b1de 100644 --- a/openjpegnet/openjpegnet.csproj +++ b/openjpegnet/openjpegnet.csproj @@ -22,7 +22,7 @@ pdbonly true - bin\Release\ + ..\bin\ TRACE prompt 4 @@ -46,4 +46,7 @@ --> + + cp $(ProjectDir)\openjpeg.dll $(TargetDir) + \ No newline at end of file