Class: LibSL::SearchManager

Inherits:
Object
  • Object
show all
Defined in:
lib/search.rb

Constant Summary collapse

PARCEL_CATEGORIES =
{
	:none => 0,
	:linden => 1,
	:adult => 2,
	:arts => 3,
	:business => 4,
	:educational => 5,
	:gaming => 6,
	:hangout => 7,
	:newcomer => 8,
	:park => 9,
	:residential => 10,
	:shopping => 11,
	:stage => 12,
	:other => 13,
	:any => -1
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ SearchManager

Returns a new instance of SearchManager.



37
38
39
40
41
# File 'lib/search.rb', line 37

def initialize(client)
	@client = client
	@results = []
	register_handlers
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



34
35
36
# File 'lib/search.rb', line 34

def client
  @client
end

#resultsObject (readonly)

Returns the value of attribute results.



35
36
37
# File 'lib/search.rb', line 35

def results
  @results
end

Instance Method Details

#event(query, mature = false, start = 0) {|SearchResult| ... } ⇒ Object

Start an event search query. Searches for all upcoming events.

Parameters:

  • query (String)

    The query string to search for

  • mature (Bool) (defaults to: false)

    (optional) Whether to include mature events

  • start (Integer) (defaults to: 0)

    (optional) Pagination support

Yields:



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/search.rb', line 113

def event(query, mature=false, start=0, &block)
	query_id = LLUUID.new
	register_callback(query_id, block)
	flags = 0x20
	flags |= 0x2000 unless mature
	packet = DirFindQueryPacket.new({
		:AgentData => {
			:AgentID => @client.network_manager.agent_id,
			:SessionID => @client.network_manager.session_id
		},
		:QueryData => {
			:QueryID => query_id,
			:QueryText => LLVariable1.new("u|0|"+query),
			:QueryFlags => LLU32.new(flags),
			:QueryStart => LLS32.new(start)
		}
	})
	@client.network_manager.send_packet packet
end

#group(query, start = 0) {|SearchResult| ... } ⇒ Object

Start a group search query

Parameters:

  • query (String)

    The query string to search for

  • start (Integer) (defaults to: 0)

    (optional) Pagination support

Yields:



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/search.rb', line 89

def group(query, start=0, &block)
	query_id = LLUUID.new
	register_callback(query_id, block)
	flags = 0x10
	packet = DirFindQueryPacket.new({
		:AgentData => {
			:AgentID => @client.network_manager.agent_id,
			:SessionID => @client.network_manager.session_id
		},
		:QueryData => {
			:QueryID => query_id,
			:QueryText => LLVariable1.new(query),
			:QueryFlags => LLU32.new(flags),
			:QueryStart => LLS32.new(start)
		}
	})
	@client.network_manager.send_packet packet
end

#person(query, online = false, start = 0) {|SearchResult| ... } ⇒ Object

Start a person search query

Parameters:

  • query (String)

    The query string to search for

  • online (Bool) (defaults to: false)

    (optional) List only online people if true

  • start (Integer) (defaults to: 0)

    (optional) Pagination support

Yields:



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/search.rb', line 65

def person(query, online=false, start=0, &block)
	query_id = LLUUID.new
	register_callback(query_id, block)
	flags = 0x01
	flags |= 0x02 if online
	packet = DirFindQueryPacket.new({
		:AgentData => {
			:AgentID => @client.network_manager.agent_id,
			:SessionID => @client.network_manager.session_id
		},
		:QueryData => {
			:QueryID => query_id,
			:QueryText => LLVariable1.new(query),
			:QueryFlags => LLU32.new(flags),
			:QueryStart => LLS32.new(start)
		}
	})
	@client.network_manager.send_packet packet
end

#pick_avatar(name) {|SearchResult| ... } ⇒ Object

Pick a list of avatars by name

Parameters:

  • name (String)

    The name to search for

Yields:



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/search.rb', line 46

def pick_avatar(name, &block)
	query_id = LLUUID.new
	register_callback(query_id, block)
	packet = AvatarPickerRequestPacket.new({
		:AgentData => {
			:AgentID => @client.network_manager.agent_id,
			:SessionID => @client.network_manager.session_id,
			:QueryID => query_id
		},
		:Data => { :Name => LLVariable1.new(name) }
	})
	@client.network_manager.send_packet packet
end

#place(query = "", sim_name = "", parcel_category = :any, start = 0) {|SearchResult| ... } ⇒ Object

Start a places search query

Parameters:

  • query (String) (defaults to: "")

    (optional) Query string. Empty string => Agent owned

  • sim_name (String) (defaults to: "")

    (optional) Restrict search to this region

  • parcel_category (Symbol) (defaults to: :any)

    (optional) See PARCEL_CATEGORIES

  • start (Integer) (defaults to: 0)

    (optional) Pagination support

Yields:



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/search.rb', line 139

def place(query="", sim_name="", parcel_category=:any, start=0, &block)
	query_id = LLUUID.new
	register_callback(query_id, block)
	flags = 0
	flags |= 0x40 if query == "" # Agent owned
	category = PARCEL_CATEGORIES[parcel_category] or -1
	packet = DirPlacesQueryPacket.new({
		:AgentData => {
			:AgentID => @client.network_manager.agent_id,
			:SessionID => @client.network_manager.session_id
		},
		:QueryData => {
			:QueryID => query_id,
			:QueryText => LLVariable1.new(query),
			:QueryFlags => LLU32.new(flags),
			:Category => LLS8.new(category),
			:SimName => LLVariable1.new(sim_name),
			:QueryStart => LLS32.new(start)
		}
	})
	@client.network_manager.send_packet packet
end