function updateNotificationCount() {
value = $("#connlbl").text();
alert("value: " + value)
$.ajax({
type: "POST",
url: "/LetsChat/GetOnlineusers?connid=" + value,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
debugger;
$('#notiContent').empty();
if (response.length == 0) {
$('#notiContent').append($('<li>Currently You Have No New users.</li>'));
}
for (var i = 0, len = response.length; i < len; i++) {
$('#notiContent').append('<strong>'+ (i+1) + "<a onclick=getValue(this); href='#'>" + response[i].ContextID + "</a>" + " " + response[i].Name + "<BR>");
// $('#online').append('<strong>' + "<a onclick=getValue(this); href='#'>" + userid + "</a>" + " " + username + "<BR>");
}
$.each(response, function (index, value) {
// $('#notiContent').append($('<li>The User: , ' + value.Name + ' ' + 'Of ID' + ' (' + index.ContextID + ') Is Written Something.</li>'));
});
},
error: errorFunc
});
}
[HttpPost]
public JsonResult GetOnlineusers(string connid)
{
NotificationComponent nc = new NotificationComponent();
var list = nc.GetData(connid);
return new JsonResult { Data = list, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
public List<users> GetData(string ExcludeConnectionid)
//public List<users> GetData(DateTime afterDate)
{
ExecuteTsql ex = new ExecuteTsql();
DataSet ds = new DataSet();
//ds= ex.SelectQueryDS("SELECT * FROM[LetsChat].[dbo].[users] where [AddedOn]>"+"'"+ afterDate+"'");
ds = ex.SelectQueryDS("SELECT * FROM[LetsChat].[dbo].[users] where contextid!="+"'" + ExcludeConnectionid +"'");
// var notificationHub = GlobalHost.ConnectionManager.GetHubContext<LetsChatHub>();
// var data = notificationHub.Clients.All.showMessage();
// await this.notificationHub.Clients.All.InvokeAsync("GetConnections");
var userList = ds.Tables[0].AsEnumerable().Select(dataRow => new users { Name = dataRow.Field<string>("Name") , ContextID = dataRow.Field<string>("ContextID") }).ToList();
return userList;
}
Member
84 Points
1323 Posts
Re: prevoius browser window notifed when new client come
Jun 01, 2019 09:19 AM|erum|LINK
i have done like this