本文整理汇总了C#中libsecondlife.SecondLife.Log方法的典型用法代码示例。如果您正苦于以下问题:C# SecondLife.Log方法的具体用法?C# SecondLife.Log怎么用?C# SecondLife.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libsecondlife.SecondLife
的用法示例。
在下文中一共展示了SecondLife.Log方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
if (args.Length != 8)
{
Console.WriteLine("Usage: importprimscript.exe [firstname] [lastname] [password] " +
"[Simulator] [x] [y] [z] [input.primscript]" +
Environment.NewLine + "Example: importprimscript.exe My Bot password " +
"Hooper 128 128 40 maya-export" + Path.DirectorySeparatorChar + "ant.primscript");
Environment.Exit(-1);
}
// Strip quotes from any arguments
for (int i = 0; i < args.Length; i++)
args[i] = args[i].Trim(new char[] { '"' });
// Parse the primscript file
string error;
List<Sculpt> sculpties = ParsePrimscript(args[7], out error);
// Check for parsing errors
if (error != String.Empty)
{
Console.WriteLine("An error was encountered reading the input file: " + error);
Environment.Exit(-2);
}
else if (sculpties.Count == 0)
{
Console.WriteLine("No primitives were read from the input file");
Environment.Exit(-3);
}
// Initialize libsecondlife
Client = new SecondLife();
Assets = new AssetManager(Client);
// Add callback handlers for asset uploads finishing. new prims spotted, and logging
Assets.OnAssetUploaded += new AssetManager.AssetUploadedCallback(Assets_OnAssetUploaded);
Client.Objects.OnNewPrim += new ObjectManager.NewPrimCallback(Objects_OnNewPrim);
Client.OnLogMessage += new SecondLife.LogCallback(Client_OnLogMessage);
// Optimize the connection for our purposes
Client.Self.Status.Camera.Far = 32.0f;
Client.Settings.MULTIPLE_SIMS = false;
Client.Settings.SEND_AGENT_UPDATES = true;
Client.Settings.ENABLE_CAPS = false;
Client.Settings.DEBUG = false;
Client.Settings.ENABLE_SIMSTATS = false;
Client.Settings.ALWAYS_REQUEST_OBJECTS = true;
Client.Settings.ALWAYS_DECODE_OBJECTS = true;
Client.Throttle.Land = 0;
Client.Throttle.Wind = 0;
Client.Throttle.Cloud = 0;
// Not sure if Asset or Texture will help with uploads, but it won't hurt
Client.Throttle.Asset = 220000.0f;
Client.Throttle.Texture = 446000.0f;
Client.Throttle.Task = 446000.0f;
int x = Int32.Parse(args[4]);
int y = Int32.Parse(args[5]);
int z = Int32.Parse(args[6]);
string start = NetworkManager.StartLocation(args[3], x, y, z);
// Attempt to login
if (!Client.Network.Login(args[0], args[1], args[2], "importprimscript 1.0.0", start,
"John Hurliman <[email protected]>"))
{
Console.WriteLine("Login failed: " + Client.Network.LoginMessage);
Environment.Exit(-4);
}
// Wait a moment for the initial flood of packets to die down
Console.WriteLine("Login succeeded, pausing for a moment...");
System.Threading.Thread.Sleep(1000 * 10);
// Set the root position for the import
RootPosition = Client.Self.Position;
RootPosition.Z += 3.0f;
for (int i = 0; i < sculpties.Count; i++)
{
// Upload the sculpt map and texture
sculpties[i].SculptID = UploadImage(sculpties[i].SculptFile, true);
sculpties[i].TextureID = UploadImage(sculpties[i].TextureFile, false);
// Check for failed uploads
if (sculpties[i].SculptID == LLUUID.Zero)
{
Client.Log("Sculpt map " + sculpties[i].SculptFile +
" failed to upload, skipping " + sculpties[i].Name, Helpers.LogLevel.Warning);
continue;
}
else if (sculpties[i].TextureID == LLUUID.Zero)
{
Client.Log("Texture " + sculpties[i].TextureFile +
" failed to upload, skipping " + sculpties[i].Name, Helpers.LogLevel.Warning);
continue;
}
LLObject.ObjectData prim = new LLObject.ObjectData();
prim.PCode = ObjectManager.PCode.Prim;
//.........这里部分代码省略.........
示例2: PersistentLogin
public static bool PersistentLogin(SecondLife client, string firstName, string lastName, string password,
string userAgent, string start, string author)
{
int unknownLogins = 0;
Start:
if (client.Network.Login(firstName, lastName, password, userAgent, start, author))
{
client.Log("Logged in to " + client.Network.CurrentSim, Helpers.LogLevel.Info);
return true;
}
else
{
if (client.Network.LoginErrorKey == "god")
{
client.Log("Grid is down, waiting 10 minutes", Helpers.LogLevel.Warning);
LoginWait(10);
goto Start;
}
else if (client.Network.LoginErrorKey == "key")
{
client.Log("Bad username or password, giving up on login", Helpers.LogLevel.Error);
return false;
}
else if (client.Network.LoginErrorKey == "presence")
{
client.Log("Server is still logging us out, waiting 1 minute", Helpers.LogLevel.Warning);
LoginWait(1);
goto Start;
}
else if (client.Network.LoginErrorKey == "disabled")
{
client.Log("This account has been banned! Giving up on login", Helpers.LogLevel.Error);
return false;
}
else if (client.Network.LoginErrorKey == "timed out")
{
client.Log("Login request timed out, waiting 1 minute", Helpers.LogLevel.Warning);
LoginWait(1);
goto Start;
}
else
{
++unknownLogins;
if (unknownLogins < 5)
{
client.Log("Unknown login error, waiting 2 minutes: " + client.Network.LoginErrorKey,
Helpers.LogLevel.Warning);
LoginWait(2);
goto Start;
}
else
{
client.Log("Too many unknown login error codes, giving up", Helpers.LogLevel.Error);
return false;
}
}
}
}
示例3: ReadBuddyMember
private static bool ReadBuddyMember(SecondLife client, XmlReader reader, out int buddyRightsGiven,
out int buddyRightsHas, out LLUUID buddyID)
{
buddyRightsGiven = 0;
buddyRightsHas = 0;
buddyID = LLUUID.Zero;
bool ret = false;
if (reader.IsStartElement("value"))
{
reader.ReadStartElement("value");
if (reader.IsStartElement("struct"))
{
reader.ReadStartElement("struct");
string name;
while (reader.IsStartElement("member"))
{
reader.ReadStartElement("member");
name = reader.ReadElementString("name");
switch (name)
{
case "buddy_rights_given":
buddyRightsGiven = ReadIntegerValue(reader);
break;
case "buddy_id":
string buddy = ReadStringValue(reader);
LLUUID.TryParse(buddy, out buddyID);
break;
case "buddy_rights_has":
buddyRightsHas = ReadIntegerValue(reader);
break;
default:
client.Log("Unhandled element in login reply (BuddyMember)",
Helpers.LogLevel.Error);
reader.Skip();
break;
}
reader.ReadEndElement();
}
reader.ReadEndElement();
ret = true;
}
reader.ReadEndElement();
}
return ret;
}
示例4: Simulator
/// <summary>
///
/// </summary>
/// <param name="client"></param>
/// <param name="callbacks"></param>
/// <param name="circuit"></param>
/// <param name="ip"></param>
/// <param name="port"></param>
public Simulator(SecondLife client, Dictionary<PacketType,List<PacketCallback>> callbacks, uint circuit,
IPAddress ip, int port)
{
Client = client;
Network = client.Network;
Callbacks = callbacks;
Region = new Region(client);
circuitCode = circuit;
Sequence = 0;
RecvBuffer = new byte[2048];
Connection = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
connected = false;
DisconnectCandidate = false;
AckTimer = new System.Timers.Timer(500);
AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
// Initialize the dictionary for reliable packets waiting on ACKs from the server
NeedAck = new Dictionary<int, Packet>();
// Initialize the lists of sequence numbers we've received so far
Inbox = new Queue<ushort>(INBOX_SIZE);
PendingAcks = new List<uint>();
Client.Log("Connecting to " + ip.ToString() + ":" + port, Helpers.LogLevel.Info);
try
{
// Setup the callback
ReceivedData = new AsyncCallback(OnReceivedData);
// Create an endpoint that we will be communicating with (need it in two
// types due to .NET weirdness)
ipEndPoint = new IPEndPoint(ip, port);
endPoint = (EndPoint)ipEndPoint;
// Associate this simulator's socket with the given ip/port and start listening
Connection.Connect(endPoint);
Connection.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref endPoint, ReceivedData, null);
// Send the UseCircuitCode packet to initiate the connection
UseCircuitCodePacket use = new UseCircuitCodePacket();
use.CircuitCode.Code = circuitCode;
use.CircuitCode.ID = Network.AgentID;
use.CircuitCode.SessionID = Network.SessionID;
// Start the ACK timer
AckTimer.Start();
// Send the initial packet out
SendPacket(use, true);
// Track the current time for timeout purposes
int start = Environment.TickCount;
while (true)
{
if (connected || Environment.TickCount - start > 8000)
{
return;
}
System.Threading.Thread.Sleep(10);
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Client.Log(e.ToString(), Helpers.LogLevel.Error);
}
}
示例5: ReadCategoryMember
private static bool ReadCategoryMember(SecondLife client, XmlReader reader, out int categoryID,
out string categoryName)
{
categoryID = 0;
categoryName = String.Empty;
bool ret = false;
if (reader.IsStartElement("value"))
{
reader.ReadStartElement("value");
if (reader.IsStartElement("struct"))
{
reader.ReadStartElement("struct");
string name;
while (reader.IsStartElement("member"))
{
reader.ReadStartElement("member");
name = reader.ReadElementString("name");
switch (name)
{
case "category_id":
categoryID = ReadIntegerValue(reader);
break;
case "category_name":
categoryName = ReadStringValue(reader);
break;
default:
client.Log("Unhandled element in login reply (CategoryMember)",
Helpers.LogLevel.Error);
reader.Skip();
break;
}
reader.ReadEndElement();
}
reader.ReadEndElement();
ret = true;
}
reader.ReadEndElement();
}
return ret;
}
示例6: Init
/// <summary>
/// </summary>
/// <param name="client"></param>
/// <param name="ctype">The type of Cache system to use for images.</param>
/// <param name="directory">The directory to use for disk based caching.</param>
private void Init(SecondLife client, CacheTypes ctype, string directory)
{
slClient = client;
// Setup Image Caching
CacheType = ctype;
if (ctype == CacheTypes.Disk)
{
if (directory != null)
{
CacheDirectory = directory;
}
try
{
if (!Directory.Exists(CacheDirectory))
{
Directory.CreateDirectory(CacheDirectory);
}
}
catch (Exception e)
{
slClient.Log("Disk Cache directory could not be established, defaulting to Memory Cache: " + Environment.NewLine +
e.ToString(), Helpers.LogLevel.Warning);
CacheType = CacheTypes.Memory;
}
}
// Image Packet Helpers
ImagePacketHelper = new ImagePacketHelpers(client);
// Image Callbacks
slClient.Network.RegisterCallback(PacketType.ImageData, new NetworkManager.PacketCallback(ImageDataCallbackHandler));
slClient.Network.RegisterCallback(PacketType.ImagePacket, new NetworkManager.PacketCallback(ImagePacketCallbackHandler));
slClient.Network.RegisterCallback(PacketType.ImageNotInDatabase, new NetworkManager.PacketCallback(ImageNotInDatabaseCallbackHandler));
}
示例7: Inventory
public Inventory(SecondLife client, InventoryManager manager, LLUUID owner)
{
Client = client;
Manager = manager;
_Owner = owner;
if (owner == LLUUID.Zero)
client.Log("Inventory owned by nobody!", Helpers.LogLevel.Warning);
Items = new Dictionary<LLUUID, InventoryNode>();
}
示例8: Simulator
/// <summary>
/// Constructor for Simulator
/// </summary>
/// <param name="client"></param>
/// <param name="callbacks"></param>
/// <param name="circuit"></param>
/// <param name="ip"></param>
/// <param name="port"></param>
public Simulator(SecondLife client, Dictionary<PacketType, List<NetworkManager.PacketCallback>> callbacks,
uint circuit, IPAddress ip, int port)
{
Client = client;
Network = client.Network;
Callbacks = callbacks;
Region = new Region(client);
circuitCode = circuit;
Inbox = new Queue<uint>(Client.Settings.INBOX_SIZE);
AckTimer = new System.Timers.Timer(Client.Settings.NETWORK_TICK_LENGTH);
AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
// Initialize the callback for receiving a new packet
ReceivedData = new AsyncCallback(OnReceivedData);
Client.Log("Connecting to " + ip.ToString() + ":" + port, Helpers.LogLevel.Info);
try
{
// Create an endpoint that we will be communicating with (need it in two
// types due to .NET weirdness)
ipEndPoint = new IPEndPoint(ip, port);
endPoint = (EndPoint)ipEndPoint;
// Associate this simulator's socket with the given ip/port and start listening
Connection.Connect(endPoint);
Connection.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref endPoint, ReceivedData, null);
// Send the UseCircuitCode packet to initiate the connection
UseCircuitCodePacket use = new UseCircuitCodePacket();
use.CircuitCode.Code = circuitCode;
use.CircuitCode.ID = Network.AgentID;
use.CircuitCode.SessionID = Network.SessionID;
// Start the ACK timer
AckTimer.Start();
// Send the initial packet out
SendPacket(use, true);
// Track the current time for timeout purposes
int start = Environment.TickCount;
while (true)
{
if (connected || Environment.TickCount - start > Client.Settings.SIMULATOR_TIMEOUT)
{
return;
}
System.Threading.Thread.Sleep(10);
}
}
catch (Exception e)
{
Client.Log(e.ToString(), Helpers.LogLevel.Error);
}
}
示例9: Shoot
/// <summary>
/// Enters mouselook, presses and releases the left mouse button, and leaves mouselook
/// </summary>
/// <returns></returns>
public static bool Shoot(SecondLife client)
{
if (client.Settings.SEND_AGENT_UPDATES)
{
client.Self.Movement.Mouselook = true;
client.Self.Movement.MLButtonDown = true;
client.Self.Movement.SendUpdate();
client.Self.Movement.MLButtonUp = true;
client.Self.Movement.MLButtonDown = false;
client.Self.Movement.FinishAnim = true;
client.Self.Movement.SendUpdate();
client.Self.Movement.Mouselook = false;
client.Self.Movement.MLButtonUp = false;
client.Self.Movement.FinishAnim = false;
client.Self.Movement.SendUpdate();
return true;
}
else
{
client.Log("Attempted Shoot but agent updates are disabled", Helpers.LogLevel.Warning);
return false;
}
}