Is there an easier way to get the MUC JID?

16 views
Skip to first unread message

DaveInNYC

unread,
Nov 29, 2009, 12:20:42 PM11/29/09
to jabber-net
Because of the asynchronous nature of receiving disco information, I
have to use a convoluted series of callbacks to get to the information
I need, in this case the JID of the MUC server. Below is my code; am I
missing some simpler way to do this? Thanks.

void JabberClient_OnAuthenticate(object sender)
{
DiscoManager.BeginGetFeatures(null, (a, b, c) => OnGetFeatures(),
null);
}

void OnGetFeatures()
{
DiscoManager.Root.AddItemsCallback(null, (a, b, c) =>
OnRootChildrenCreated(), null);
}

int _rootChildrenPending;
void OnRootChildrenCreated()
{
_rootChildrenPending = DiscoManager.Root.Children.Count;
foreach (DiscoNode child in DiscoManager.Root.Children)
{
child.AddFeatureCallback(DiscoManager, (a, b, c) =>
OnRootChildPopulated(), null);
}
}

void OnRootChildPopulated()
{
lock (DiscoManager.Root)
{
_rootChildrenPending--;
if (_rootChildrenPending == 0)
{
SetMucId();
}
}
}

private WaitableValue<JID> MucId { get; set; }

private void SetMucId()
{
JID mucComponent = null;

foreach (DiscoNode component in DiscoManager.Root.Children)
{
if (component.HasFeature(jabber.protocol.URI.MUC))
{
mucComponent = component.JID;
break;
}
}
MucId.Value = mucComponent;
}

Joe Hildebrand

unread,
Dec 3, 2009, 11:59:03 AM12/3/09
to jabbe...@googlegroups.com
Yes. Try: DiscoManager.BeginFindServiceWithFeature
> --
>
> You received this message because you are subscribed to the Google Groups "jabber-net" group.
> To post to this group, send email to jabbe...@googlegroups.com.
> To unsubscribe from this group, send email to jabber-net+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jabber-net?hl=en.
>
>

DaveInNYC

unread,
Dec 4, 2009, 2:17:46 PM12/4/09
to jabber-net
Thanks, will give it a shot. I *knew* there had to be a better way....
> > For more options, visit this group athttp://groups.google.com/group/jabber-net?hl=en.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages