Re: I don't see Chat Room

  •  06-22-2006, 11:18 AM

    Re: I don't see Chat Room

    You need to create a page which can show the chat rooms.
     
    In the web page, you need to create a datalist control and populate it with CuteChat rooms.
     
    Here are some example code.
     
    You can modify it to meet your own requirements.
     
             <ASP:DataList id="DataList_Lobbies" CellSpacing="3" Width="400" RepeatColumns="2" runat="server">
                   <ItemTemplate>
                        <asp:HyperLink ID="lnkLobby" Runat="server">
                         <nobr><img src="images/home.gif" width="49" height="49" border="0" align="middle"><%#DataBinder.Eval(Container.DataItem, "Name")%></nobr>
                        </asp:HyperLink>
                        <br>
                        (<asp:Label ID="lblOnlineChater" Runat="server"></asp:Label> chatting)
                 </ItemTemplate>
             </ASP:DataList>
     
     
    <script runat="server">
      
      private void Page_Load(object sender, System.EventArgs e)
      {
       if (! this.IsPostBack)
       {
        ArrayList lobbies=new ArrayList();
        foreach(CuteChatLobby lobby in ChatApi.GetLobbyArray())
        {
         if(lobby.IsHidden)
          continue;
         lobbies.Add(lobby);
        }
        this.DataList_Lobbies.DataSource = lobbies;
        this.DataList_Lobbies.ItemDataBound+=new DataListItemEventHandler(rptLobbies_ItemDataBound);
        this.DataList_Lobbies.DataBind();
       }   
      }
      
      private void rptLobbies_ItemDataBound(object sender, DataListItemEventArgs e)
      {
       if (e.Item.DataItem == null)
       {
        return;
       }
       CuteChatLobby lobby = e.Item.DataItem as CuteChatLobby;
         
       HyperLink lnkLobby = e.Item.FindControl("lnkLobby") as HyperLink;
       lnkLobby.NavigateUrl = CuteSoft.Chat.ChatWebUtility.ResolveResource(this.Context, "CH_MainForm.Aspx") + "?Location=Lobby&LocationId=" + lobby.LobbyId.ToString();
       lnkLobby.Target = "_blank";
       String sOnlineChater = "";
       int len=0;
       foreach(CuteChatClient chater in ChatApi.GetLobbyClientArray(lobby.LobbyId))
       {
        if(chater.ActiveTime > DateTime.Now-TimeSpan.FromSeconds(30) )
        {
         sOnlineChater += chater.DisplayName + "  ";
         len++;
        }
       }
       Label lblOnlineChater = e.Item.FindControl("lblOnlineChater") as Label;
       lblOnlineChater.Text = len.ToString();
       lnkLobby.ToolTip = sOnlineChater;
      }
      </script>
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

View Complete Thread