Total # of Chatters in all Rooms

Last post 01-22-2008, 5:45 PM by GOTBUD. 2 replies.
Sort Posts: Previous Next
  •  01-02-2008, 2:36 PM 36116

    Total # of Chatters in all Rooms

    Is there anyway to get a total number of chatters in all rooms, so that I can place that on my home page?
  •  01-07-2008, 8:35 AM 36180 in reply to 36116

    Re: Total # of Chatters in all Rooms

    Hi:
     
    Here is a example about how to list the online users:
     
    you can just count it :
     
    int count=0;
    ChatPortal portal=ChatSystem.Instance.GetCurrentPortal();
    lock(portal)
    {
       foreach(ChatChannel channel in portal.GetStartedChannels())
       {
          count+=channel.GetAllUsers().Length;
       }
    }
     
     
    full example:

    <%@ Page Language="C#" %>
    <%@ Import Namespace="CuteChat" %>
    <script runat=server>
    static string Encode(string val)
    {
     if(val==null)return "";
     return val.Replace("\\","\\\\").Replace("\"","\\\\");
    }
    </script>

    var onlineusers=[];

    <%
    ChatPortal portal=ChatSystem.Instance.GetCurrentPortal();
    lock(portal)
    {

    foreach(ChatChannel channel in portal.GetStartedChannels())
    {
    foreach(ChatPlaceUser user in channel.GetAllUsers())
    {
     if(user.AppearOffline)continue;

    %>

    onlineusers.push({
    UserId:"<%=user.Identity.UniqueId%>"
    ,
    Name:"<%=Encode(user.DisplayName)%>"
    ,
    IsGuest:<%=user.Identity.IsAnonymous?"true":"false"%>
    });


    <%}%>

    <%}%>

    <%}%>


    for(var i=0;i<onlineusers.length;i++)
    {
     var user=onlineusersIdea;
     document.write("<span class='onlineuser'>");
     document.write(user.Name);
     document.write("</span>");
    }

     
    Regards , Terry.
  •  01-22-2008, 5:45 PM 36468 in reply to 36180

    Re: Total # of Chatters in all Rooms

    Terry,
     
    I also gave the code above a try using CuteChat 4.0 and Community Server 2007. The only thing that would display using that bit of code was something like " response.write = "  something or other..
     
    So I found this code in one of the Cute Chat files and gave it a try. It now lists all 6 rooms I have with the number of chatters in each room. I am ok with that. EX.

    Public Conference Room #1
    ( 1 chatting)
     
    My question is, How would I only display or filter to show either by LobbyID or RoomName. Say if i only want LobbyId -3, -5, and -7 .  Here is the code i have on my home page in CS 2007:

    <table cellspacing="1" border="0" cellpadding="5" width="50%">

    <tr><td><ASP:DataList id="DataList_Lobbies" CellSpacing="3" Width="100%" RepeatColumns="1" runat="server">

    <ItemTemplate>

    <asp:Label ID="lnkLobby" Runat="server">

    <%="<"%><%="script"%><%=" src='"%><%=ResolveUrl("/Chat/IntegrationUtility.js.aspx")%><%="'"%><%=">"%><%="<"%><%="/script"%><%=">"%>

    <nobr>

    <%#DataBinder.Eval(Container.DataItem, "Name")%></nobr>

    <br />

    (

    <asp:Label ID="lblOnlineChater" Runat="server"></asp:Label>

    chatting)

    </asp:Label></ItemTemplate></ASP:DataList> </td></tr></table>

    Thanks for your time, Jay

    Filed under:
View as RSS news feed in XML