private bool TryGetGroupsService(UGI ugi, out GroupsBrokerEntry groupsService) { groupsService = default(GroupsBrokerEntry); Dictionary <string, string> cachedheaders; GroupsBrokerEntry entry; if (ugi.HomeURI == null) { return(false); } if (ugi.AuthorizationToken == null) { /* if unset, try fetching the authorization token */ UGI ugi2; if (m_GroupsNameService.TryGetValue(ugi.ID, out ugi2)) { ugi = ugi2; if (ugi.HomeURI == null) { return(false); } } } string groupsServerURI = ugi.HomeURI.ToString(); if (m_GroupsService != null && m_GroupsHomeURI == groupsServerURI) { entry = new GroupsBrokerEntry(m_GroupsService, m_GroupIMRouter, m_ClockSource.TickCount); m_NameCache[ugi.ID] = entry; groupsService = entry; return(true); } cachedheaders = ServicePluginHelo.HeloRequest(groupsServerURI); foreach (IGroupsServicePlugin plugin in m_GroupsServicePlugins) { if (plugin.IsProtocolSupported(groupsServerURI, cachedheaders)) { GroupsServiceInterface service = plugin.Instantiate(ugi); IGroupsChatServiceInterface chatService = service as IGroupsChatServiceInterface; if (chatService == null) { /* do not search for it if the groups connector has it integrated */ foreach (IGroupsChatServicePlugin chatplugin in m_GroupsChatServicePlugins) { if (chatplugin.IsProtocolSupported(groupsServerURI, cachedheaders)) { chatService = chatplugin.Instantiate(ugi); break; } } } entry = new GroupsBrokerEntry(service, chatService, m_ClockSource.TickCount); m_NameCache[ugi.ID] = entry; groupsService = entry; return(true); } } return(false); }
public GroupsBrokerEntry(GroupsServiceInterface innerGroupsService, IGroupsChatServiceInterface innerGroupsChatService, long expiryTickCount) { InnerGroupsService = innerGroupsService; InnerGroupsChatService = innerGroupsChatService; ExpiryTickCount = expiryTickCount; }