Arun vs. BeagleClient -- round 1



Hello All,
I've run into a bit of a hitch while trying to write some code that
uses the BeagleClient API to connect to beagled and do some searching.

I've attached the code for a Search class. I instantiate an object
with the query "xesam". I see the search happening on the beagled
side, but the HitsAdded event does not occur. The Main() method runs
an infinite loop iterating on DBus messages waiting for this.

Anybody got any clues on why I'm not getting callbacks on OnHitAdded?
I can post all the code if required, but it's a little messy right
now.

TIA!
--
Arun Raghavan
(http://nemesis.accosted.net)
v2sw5Chw4+5ln4pr6$OFck2ma4+9u8w3+1!m?l7+9GSCKi056
e6+9i4b8/9HTAen4+5g4/8APa2Xs8r1/2p5-8 hackerkey.com
//
// Search.cs : Translation between BeagleClient API and Xesam(-like) API
//
// Copyright (C) 2007 Arun Raghavan <arunissatan gmail com>
//

//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//

using System;
using Beagle;

namespace Beagle {
	namespace Xesam {
		public class Search {
			private Query query;
			private string id;
			public event Searcher.HitsAddedMethod HitsAddedHandler;

			public Search(string myID, string qTxt)
			{
				id = myID;
				query = new Query();
				query.AddDomain (QueryDomain.Neighborhood);

				// Don't search documentation by default
				QueryPart_Property part = new QueryPart_Property ();
				part.Logic = QueryPartLogic.Prohibited;
				part.Type = PropertyType.Keyword;
				part.Key = "beagle:Source";
				part.Value = "documentation";
				query.AddPart(part);

				query.AddText(qTxt);

				query.HitsAddedEvent += OnHitsAdded;
				query.HitsSubtractedEvent += OnHitsSubtracted;
				query.FinishedEvent += OnFinished;
			}

			public void Start()
			{
				Console.Error.WriteLine("SendAsync() started");
				query.SendAsync();
				Console.Error.WriteLine("SendAsync() done");
			}

			private void OnHitsAdded(HitsAddedResponse response)
			{
				// cache the hits and keep them nice and safe
				Console.Error.WriteLine("{0}: Got some hits: {1}", id, response.NumMatches);
				foreach (Hit hit in response.Hits) {
					Console.Error.WriteLine("Hit: {0}", hit.Uri);
				}
				HitsAddedHandler(id, response.NumMatches);
			}

			private void OnHitsSubtracted(HitsSubtractedResponse response)
			{
				Console.Error.WriteLine("Removed some hits");
			}

			private void OnFinished(FinishedResponse response)
			{
				Console.Error.WriteLine("Search finished");
			}

		}
	}
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]