Exemplo n.º 1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (AMS.Web.RemoteScripting.InvokeMethod(this))            //if this is a callback function return
            {
                return;
            }

            txtMsg.Attributes.Add("onkeypress", "return clickButton(event,'btn')");

            if (!IsPostBack)
            {
                if (Request.QueryString["userid"] != null && Request.QueryString["userid"] != "")
                {
                    otherUser.Value = Request.QueryString["userid"];
                    ChatRoom room = ChatEngine.GetRoom(Session["UserName"].ToString(), Request.QueryString["userid"]);
                    string   s    = room.JoinRoom(Session["UserName"].ToString(), Session["UserName"].ToString());
                    txt.InnerText = s;
                    //	string strScript="<script>startTimer();</script>";
                    //	this.RegisterClientScriptBlock("timerScript",strScript);
                }
                else
                {
                    Response.Write("User id Missing");
                    pnlChat.Visible = false;
                }
            }
        }
Exemplo n.º 2
0
 protected void btnExit_Click(object sender, System.EventArgs e)
 {
     try
     {
         ChatRoom room = ChatEngine.GetRoom(Session["UserName"].ToString(), Request.QueryString["userid"]);
         room.LeaveRoom(Session["UserName"].ToString());
         //	string  strScript = "<script language=javascript>self.close();</script>";
         //	RegisterClientScriptBlock("anything", strScript);
         Response.Redirect("default.aspx");
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// This function is called from the client when the user is about to leave the room
 /// </summary>
 /// <param name="otherUser"></param>
 /// <returns></returns>
 public string LeaveRoom(string otherUser)
 {
     try
     {
         ChatRoom room = ChatEngine.GetRoom(Session["UserName"].ToString(), otherUser);
         if (room != null)
         {
             room.LeaveRoom(Session["UserName"].ToString());
         }
     }
     catch (Exception ex)
     {
     }
     return("");
 }
Exemplo n.º 4
0
 /// <summary>
 /// This function is called from the client script
 /// </summary>
 /// <param name="msg"></param>
 /// <param name="toUserID"></param>
 /// <returns></returns>
 public string SendMessage(string msg, string toUserID)
 {
     try
     {
         ChatRoom room = ChatEngine.GetRoom(Session["UserName"].ToString(), toUserID);
         string   res  = "";
         if (room != null)
         {
             res = room.SendMessage(msg, Session["UserName"].ToString(), toUserID);
         }
         return(res);
     }
     catch (Exception ex)
     {
     }
     return("");
 }
Exemplo n.º 5
0
 /// <summary>
 /// This function is called peridically called from the user to update the messages
 /// </summary>
 /// <param name="otherUserID"></param>
 /// <returns></returns>
 public string UpdateUser(string otherUserID)
 {
     try
     {
         ChatRoom room = ChatEngine.GetRoom(Session["UserName"].ToString(), otherUserID);
         if (room != null)
         {
             string res = "";
             if (room != null)
             {
                 res = room.UpdateUser(Session["UserName"].ToString());
             }
             return(res);
         }
     }
     catch (Exception ex)
     {
     }
     return("");
 }