static public string LeaveRoom(string roomID) { try { ChatRoom room = ChatEngine.GetRoom(roomID); if (room != null) { room.LeaveRoom(HttpContext.Current.Session["UserName"].ToString()); } } catch (Exception ex) { } return(""); }
static public string SendMessage(string msg, string roomID) { try { ChatRoom room = ChatEngine.GetRoom(roomID); string res = ""; if (room != null) { res = room.SendMessage(msg, HttpContext.Current.Session["UserName"].ToString()); } return(res); } catch (Exception ex) { } return(""); }
static public string UpdateUser(string roomID) { try { ChatRoom room = ChatEngine.GetRoom(roomID); if (room != null) { string res = ""; if (room != null) { res = room.UpdateUser(HttpContext.Current.Session["UserName"].ToString()); } return(res); } } catch (Exception ex) { } return(""); }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserName"] == null) { Response.Redirect("Default.aspx"); } txtMsg.Attributes.Add("onkeypress", "return clickButton(event,'btn')"); if (!IsPostBack) { hdnRoomID.Value = Request.QueryString["rid"]; ChatRoom room = ChatEngine.GetRoom(hdnRoomID.Value); string prevMsgs = room.JoinRoom(Session["UserName"].ToString(), Session["UserName"].ToString()); txt.Text = prevMsgs; foreach (string s in room.GetRoomUsersNames()) { lstMembers.Items.Add(new ListItem(s, s)); } } }
static public string UpdateRoomMembers(string roomID) { try { ChatRoom room = ChatEngine.GetRoom(roomID); if (room != null) { IEnumerable <string> users = room.GetRoomUsersNames(); string res = ""; foreach (string s in users) { res += s + ","; } return(res); } } catch (Exception ex) { } return(""); }