DirectoryManager.StartLandSearch

From libopenmetaverse - libomv - Developer Wiki

Jump to: navigation, search

Contents

Prerequisites

CSharp Tutorials
Getting Started
How to create a basic libSL bot
SecondLife.Network Events

Introduction

The following class demonstrates how to use DirectoryManager.StartLandSearch() to find MainLand Parcels.

C# Code

 
using System;
using System.Collections.Generic;
using libsecondlife;
 
namespace DirectoryLandSearch
{
	class Program
	{
		#region Fields
		private static SecondLife client;
		private static string firstname = "First";
		private static string lastname = "Last";
		private static string password = "Password";
		private static LLUUID landsearchuuid;
		#endregion
 
 
		#region Methods
		static void Main ( string[] args )
		{
 
			client = new SecondLife();
 
			// Listen to Network events
			client.Network.OnConnected += new NetworkManager.ConnectedCallback( Network_OnConnected );
 
			// Listen to Directory events
			client.Directory.OnDirLandReply +=new DirectoryManager.DirLandReplyCallback(Directory_OnDirLandReply);
 
			// Log in to Second Life Simulator
			if ( !client.Network.Login( firstname, lastname, password, "Land Search Client", "1.0" ) )
				Console.WriteLine( client.Network.LoginMessage + "\r\n" );
 
			// Make main thread wait for events
			Console.WriteLine( "\n-- Press any key to log out and close --\n" );
			Console.Read();
			Console.WriteLine( "Logging out..." );
			client.Network.Logout();
 
		}
		#endregion
 
 
		#region Network Events
		static void Network_OnConnected ( object sender )
		{
			landsearchuuid = client.Directory.StartLandSearch(
				DirectoryManager.SearchTypeFlags.Mainland
				);
			
		}
		#endregion
 
 
		#region Directory Events
		static void Directory_OnDirLandReply ( List<DirectoryManager.DirectoryParcel> dirParcels )
		{
			foreach ( DirectoryManager.DirectoryParcel parcel in dirParcels )
			{
				Console.WriteLine(
					"Name: {0}\nPrice: {1}\nArea {2}\n",
					parcel.Name,
					parcel.SalePrice.ToString( "'$L'#,#.00" ),
					parcel.ActualArea.ToString( "#,#" )
					);
			}
		}
		#endregion
	}
}
 



Typical Output

INFO [firstname lastname]: Connecting to (8.2.35.39:13001)
INFO [firstname lastname]: Received a region handshake for Sandbox Cordova (8.2.35.39:13001)

-- Press any key to log out and close --

Name: Protected road and view
Price: $L5,300.00
Area 1,696

Name: Eiras - Shantos
Price: $L1,609.00
Area 512

Name: Top Villa
Price: $L1,620.00
Area 512

Name: Eiras - Croix
Price: $L1,644.00
Area 512

Name: Eiras - Maekju
Price: $L1,439.00
Area 448

Name: SWEET HEART LAND SALES
Price: $L1,648.00
Area 512

Name: Eiras - Krypto
Price: $L1,649.00
Area 512

Name: Eiras - Mullett
Price: $L1,649.00
Area 512

(Most search results cut for brevity)

INFO [firstname lastname]: Connecting to (216.82.18.252:13001)
INFO [firstname lastname]: Connecting to (63.210.157.87:13000)
INFO [firstname lastname]: Connecting to (63.210.159.124:13002)
INFO [firstname lastname]: Received a region handshake for Georgean (63.210.157.87:13000)
INFO [firstname lastname]: Received a region handshake for Sandbox Goguen (63.210.159.124:13002)
INFO [firstname lastname]: Got EstablishAgentCommunication for Georgean (63.210.157.87:13000)
INFO [firstname lastname]: Got EstablishAgentCommunication for Sandbox Goguen (63.210.159.124:13002)
INFO [firstname lastname]: Received a region handshake for Abbotts (216.82.18.252:13001)
INFO [firstname lastname]: Got EstablishAgentCommunication for Abbotts (216.82.18.252:13001)
DEBUG [firstname lastname]: No handler registered for packet event AvatarAppearance
DEBUG [firstname lastname]: No handler registered for packet event AvatarAppearance

Logging out...
INFO [firstname lastname]: Logging out
INFO [firstname lastname]: NetworkManager shutdown initiated
INFO [firstname lastname]: Caps system for Abbotts (216.82.18.252:13001) is aborting
INFO [firstname lastname]: Caps system for Georgean (63.210.157.87:13000) is aborting
INFO [firstname lastname]: Caps system for Sandbox Goguen (63.210.159.124:13002) is aborting
INFO [firstname lastname]: Caps system for Sandbox Cordova (8.2.35.39:13001) is aborting


Author

Drew Lorefield