/// <summary> /// Finds a component that implements a given feature, which is a child of /// the root. This will call back on the first match. It will call back /// with null if none are found. /// </summary> /// <param name="featureURI">Feature to look for.</param> /// <param name="handler">Callback to use when finished.</param> /// <param name="state">Context to pass back to caller when complete</param> public void BeginFindServiceWithFeature(string featureURI, DiscoNodeHandler handler, object state) { if (handler == null) { return; // prove I *didn't* call it. :) } FindServiceRequest req = new FindServiceRequest(featureURI, handler); BeginGetItems(Root, new DiscoNodeHandler(req.GotRootItems), state); // hopefully enough to prevent GC. }
/// <summary> /// Retrieves the child items associated with this node, /// and then calls back on the handler. /// If the information is in the cache, handler gets /// called right now. /// </summary> /// <param name="node">Disco node to search.</param> /// <param name="handler">Callback that gets called with the items.</param> /// <param name="state">Context to pass back to caller when complete</param> public void BeginGetItems(DiscoNode node, DiscoNodeHandler handler, object state) { if (node == null) { node = Root; } if (node.AddItemsCallback(this, handler, state)) { RequestItems(node); } }
/// <summary> /// Retrieves the features associated with this node and /// then calls back on the handler. /// If the information is in the cache, handler gets called right now. /// </summary> /// <param name="node">Node to look for.</param> /// <param name="handler">Callback to use afterwards.</param> /// <param name="state">Context to pass back to caller when complete</param> public void BeginGetFeatures(DiscoNode node, DiscoNodeHandler handler, object state) { if (node == null) { node = Root; } if (node.AddFeatureCallback(this, handler, state)) { RequestInfo(node); } }
/// <summary> /// Add a callback for when identities are received. /// /// Calls the callback immediately if the features have already been retrieved. /// </summary> /// <param name="manager"></param> /// <param name="callback"></param> /// <param name="state"></param> /// <returns>True if there were no identities yet, and the callback was queued.</returns> public bool AddIdentityCallback(DiscoManager manager, DiscoNodeHandler callback, object state) { lock (this) { if (Identities != null) { if (callback != null) { callback(manager, this, state); } return(false); } else { m_identCallbacks.Add(new NodeCallback(manager, callback, state)); return(true); } } }
public void GotFeatures(DiscoManager manager, DiscoNode node, object state) { // yes, yes, this may call the handler more than once in multi-threaded world. Punt for now. if (m_handler != null) { if (node.HasFeature(m_URI)) { m_handler(manager, node, state); m_handler = null; } } if (Interlocked.Decrement(ref m_outstanding) == 0) { if (m_handler != null) { m_handler(manager, null, state); } } }
/// <summary> /// Add a callback for when items are received. /// /// Calls the callback immediately if the items have already been retrieved. /// </summary> /// <param name="manager"></param> /// <param name="callback"></param> /// <param name="state"></param> /// <returns>True if there were no items yet, and the callback was queued.</returns> public bool AddItemsCallback(DiscoManager manager, DiscoNodeHandler callback, object state) { lock (this) { if (Children != null) { if (callback != null) { callback(manager, this, state); } return(false); } else { if (callback != null) { m_itemCallbacks.Add(new NodeCallback(manager, callback, state)); } return(true); } } }
/// <summary> /// Add a callback for when features are received. /// /// Calls the callback immediately if the features have already been retrieved. /// </summary> /// <param name="manager"></param> /// <param name="callback"></param> /// <param name="state"></param> /// <returns>True if there were no features yet, and the callback was queued.</returns> public bool AddFeatureCallback(DiscoManager manager, DiscoNodeHandler callback, object state) { lock (this) { if (Features != null) { if (callback != null) { callback(manager, this, state); } return(false); } else { if (callback != null) { m_featureCallbacks.Add(new NodeCallback(manager, callback, state)); } return(true); } } }
/// <summary> /// Add a callback for when features are received. /// /// Calls the callback immediately if the features have already been retrieved. /// </summary> /// <param name="manager"></param> /// <param name="callback"></param> /// <param name="state"></param> /// <returns>True if there were no features yet, and the callback was queued.</returns> public bool AddFeatureCallback(DiscoManager manager, DiscoNodeHandler callback, object state) { lock (this) { if (Features != null) { if (callback != null) callback(manager, this, state); return false; } else { if (callback != null) m_featureCallbacks.Add(new NodeCallback(manager, callback, state)); return true; } } }
public NodeCallback(DiscoManager m, DiscoNodeHandler h, object s) { manager = m; callback = h; state = s; }
/// <summary> /// Finds a component that implements a given feature, which is a child of /// the root. This will call back on the first match. It will call back /// with null if none are found. /// </summary> /// <param name="featureURI">Feature to look for.</param> /// <param name="handler">Callback to use when finished.</param> /// <param name="state">Context to pass back to caller when complete</param> public void BeginFindServiceWithFeature(string featureURI, DiscoNodeHandler handler, object state) { if (handler == null) return; // prove I *didn't* call it. :) FindServiceRequest req = new FindServiceRequest(featureURI, handler); BeginGetItems(Root, new DiscoNodeHandler(req.GotRootItems), state); // hopefully enough to prevent GC. }
public void GotFeatures(DiscoManager manager, DiscoNode node, object state) { // yes, yes, this may call the handler more than once in multi-threaded world. Punt for now. if (m_handler != null) { if (node.HasFeature(m_URI)) { m_handler(manager, node, state); m_handler = null; } } if (Interlocked.Decrement(ref m_outstanding) == 0) { if (m_handler != null) m_handler(manager, null, state); } }
public FindServiceRequest(string featureURI, DiscoNodeHandler handler) { m_URI = featureURI; m_handler = handler; }
/// <summary> /// Retrieves the child items associated with this node and JID, /// and then calls back on the handler. /// If the information is in the cache, handler gets /// called right now. /// </summary> /// <param name="jid">JID of Service to query.</param> /// <param name="node">Node on the service to interact with.</param> /// <param name="handler">Callback that gets called with the items.</param> /// <param name="state">Context to pass back to caller when complete</param> public void BeginGetItems(JID jid, string node, DiscoNodeHandler handler, object state) { BeginGetItems(GetNode(jid, node), handler, state); }
/// <summary> /// Retrieves the child items associated with this node, /// and then calls back on the handler. /// /// If caching is specified, items already in the cache call the handler /// immediately. /// </summary> /// <param name="jid">JID of Service to query.</param> /// <param name="node">Node on the service to interact with.</param> /// <param name="handler">Callback that gets called with the items.</param> /// <param name="state">Context to pass back to caller when complete</param> /// <param name="cache">Should caching be performed on this request?</param> public void BeginGetItems(JID jid, string node, DiscoNodeHandler handler, object state, bool cache) { DiscoNode dn = cache ? GetNode(jid, node) : new DiscoNode(jid, node); BeginGetItems(dn, handler, state); }
/// <summary> /// Retrieves the child items associated with this node, /// and then calls back on the handler. /// If the information is in the cache, handler gets /// called right now. /// </summary> /// <param name="node">Disco node to search.</param> /// <param name="handler">Callback that gets called with the items.</param> /// <param name="state">Context to pass back to caller when complete</param> public void BeginGetItems(DiscoNode node, DiscoNodeHandler handler, object state) { if (node == null) node = Root; if (node.AddItemsCallback(this, handler, state)) RequestItems(node); }
/// <summary> /// Add a callback for when items are received. /// /// Calls the callback immediately if the items have already been retrieved. /// </summary> /// <param name="manager"></param> /// <param name="callback"></param> /// <param name="state"></param> /// <returns>True if there were no items yet, and the callback was queued.</returns> public bool AddItemsCallback(DiscoManager manager, DiscoNodeHandler callback, object state) { lock (this) { if (Children != null) { if (callback != null) callback(manager, this, state); return false; } else { if (callback != null) m_itemCallbacks.Add(new NodeCallback(manager, callback, state)); return true; } } }
/// <summary> /// Add a callback for when identities are received. /// /// Calls the callback immediately if the features have already been retrieved. /// </summary> /// <param name="manager"></param> /// <param name="callback"></param> /// <param name="state"></param> /// <returns>True if there were no identities yet, and the callback was queued.</returns> public bool AddIdentityCallback(DiscoManager manager, DiscoNodeHandler callback, object state) { lock (this) { if (Identities != null) { if (callback != null) callback(manager, this, state); return false; } else { m_identCallbacks.Add(new NodeCallback(manager, callback, state)); return true; } } }
/// <summary> /// Retrieves the features associated with this node and /// then calls back on the handler. /// If the information is in the cache, handler gets called right now. /// </summary> /// <param name="node">Node to look for.</param> /// <param name="handler">Callback to use afterwards.</param> /// <param name="state">Context to pass back to caller when complete</param> public void BeginGetFeatures(DiscoNode node, DiscoNodeHandler handler, object state) { if (node == null) node = Root; if (node.AddFeatureCallback(this, handler, state)) RequestInfo(node); }