private void IMSessionStarted(GroupInstantMessage im) { if (!m_GroupsService.Members.ContainsKey(im.FromAgent, im.ToGroup, im.FromAgent)) { throw new Exception("Not a member"); } GroupSession session = m_ActiveChats.GetOrAddIfNotExists(im.ToGroup.ID, () => new GroupSession(im.ToGroup)); im.IMSessionID = session.SessionID; im.FromGroup = im.ToGroup; try { foreach (GroupMember gm in m_GroupsService.Members[im.FromAgent, im.ToGroup]) { session.Participants.AddIfNotExists(gm.Principal); } } finally { m_ActiveSessions.RemoveIf(im.IMSessionID, (entry) => entry.Participants.Count == 0); m_ActiveChats.RemoveIf(im.ToGroup.ID, (entry) => entry.Participants.Count == 0); } DistributeMessage(session, im); }
private void IMSendThread(object s) { var service = (IMServiceHandler)s; Thread thread = Thread.CurrentThread; thread.Name = "GroupIM:Send Thread"; service.m_Threads.Add(thread); try { while (true) { GroupInstantMessage im = m_Queue.Dequeue(1000); try { if (im.IMSessionID == UUID.Zero) { IMSessionStarted(im); } else { IMSessionContinued(im); } } catch { im.OnResult(im, false); } } } catch { service.m_Threads.Remove(thread); } }
public void Send(GroupInstantMessage im) { m_Queue.Enqueue(im); lock (m_Lock) { if (m_Queue.Count > m_Threads.Count && m_Threads.Count < m_MaxThreads) { ThreadManager.CreateThread(IMSendThread).Start(this); } } }
private void DistributeMessage(GroupSession session, GroupInstantMessage im) { try { foreach (UGUI target in session.Participants) { m_IMRouter.SendWithResultDelegate(im.GetAgentIM(target)); } } catch { /* do not pass any from here since we cannot reliably say so which failed */ } }
private void IMSessionContinued(GroupInstantMessage im) { GroupSession session; if (!m_ActiveSessions.TryGetValue(im.IMSessionID, out session) || session.Group.EqualsGrid(im.ToGroup)) { IMSessionStarted(im); } else if (!m_GroupsService.Members.ContainsKey(im.FromAgent, im.ToGroup, im.FromAgent)) { throw new Exception("Not a member"); } else { DistributeMessage(session, im); } }
public void Send(GroupInstantMessage im) => GetGroupsChatService(im.ToGroup).Send(im);
public void Send(GroupInstantMessage im) { InnerGroupsChatService?.Send(im); }