In the OnInstantMessage() event in Avatar.cs is the line:

AgentName =
System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", "");

Which then passes on the string to the event handler. It shows up blank in
the event handler (although message comes through correct). I tried
replacing that line with the code below, and still it does not seem to
capture the AV name.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of John Hurliman
Sent: Thursday, July 06, 2006 10:15 PM
To: Development list for libsecondlife
Subject: Re: [libsecondlife-dev] Question regarding the AgentName
variablefor OnInstantMessage()

Any variable length fields in the packets are stored as byte arrays 
(byte[]). If you try and do a .ToString() on a byte array you won't get 
anything interesting, what you want is something like this:

byte[] byteArray = (byte[])field.Data; // Variable length fields are 
byte arrays
string output = System.Text.Encoding.ASCII.GetChars(byteArray, 0, 
byteArray.Length); // Convert the byte[] to a string
output.Replace("\0", ""); // Remove the null terminator from the end of 
the string

I know that's a pain, libsl will have a helper function that converts 
byte arrays to strings soon.

John

_______________________________________________
libsecondlife-dev mailing list
libsecondlife-dev@gna.org
https://mail.gna.org/listinfo/libsecondlife-dev


-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.9/382 - Release Date: 7/4/2006
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.9/382 - Release Date: 7/4/2006
 


_______________________________________________
libsecondlife-dev mailing list
libsecondlife-dev@gna.org
https://mail.gna.org/listinfo/libsecondlife-dev

Reply via email to