B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
i am using webforms ,keeping the username and usergroupid(manager,admin,e.t.c.) in session , only send notification based on username or usergroupid, as for authentication it is a simple query to sql db if true save the info in session
authentication it is a simple query to sql db if true save the info in session
¿ then what do you need ?
also, what have you tried?
perhaps you could show us your current relevant code snippets?
it appears to me that you've already solved your own problem ...
haider.ali
i want to send the server event to specific users(based on their usernames) any idea how to do it?
example: add a column to your user database that identifies your "specific users" -- in pseudo code:
if sql_user_type == "specific", enable display of some_server_evernt
g.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
Here is the Default.aspx file
<script type="text/javascript">
window.onload = function () {
if (window.EventSource == undefined) {
document.getElementById('targetDiv').innerHTML = "Your browser doesn't support Server Side Events.";
}
var source = new EventSource('SSEHandler.aspx');
source.onopen = function (event) {
document.getElementById('targetDiv').innerHTML += 'Connection Opened.<br>';
};
source.onerror = function (event) {
if (event.eventPhase == EventSource.CLOSED) {
document.getElementById('targetDiv').innerHTML += 'Connection Closed.<br>';
}
};
source.onmessage = function (event) {
$("#targetDiv").append(event);
};
}
</script>
<div id="targetDiv">
</div>
N.B.: you can not send the "event" ... you must handle the "event" at your server.
what you can do is to set a value such as a string variabler in your event handler to pass whatever meaningful information your end user requires ... in pseudo code:
// in event handler
String myEventMessage = " ... whatever you want your end user to know ... ";
g.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
haider.ali
0 Points
4 Posts
Sending Html5 SSE to specific clients
Jun 16, 2012 07:35 PM|LINK
i want to send the server event to specific users(based on their usernames) any idea how to do it?
gerrylowry
All-Star
20513 Points
5712 Posts
Re: Sending Html5 SSE to specific clients
Jun 16, 2012 11:43 PM|LINK
@ haider.ali
TIMTOWTDI =. there is more than one way to do it
are you using ASP.NET MVC, WebForms, other?
what form of authentication are you using?
example: http://weblogs.asp.net/jgalloway/archive/2012/04/18/asp-net-mvc-authentication-global-authentication-and-allow-anonymous.aspx
g.
haider.ali
0 Points
4 Posts
Re: Sending Html5 SSE to specific clients
Jun 17, 2012 05:54 AM|LINK
i am using webforms ,keeping the username and usergroupid(manager,admin,e.t.c.) in session , only send notification based on username or usergroupid, as for authentication it is a simple query to sql db if true save the info in session
gerrylowry
All-Star
20513 Points
5712 Posts
Re: Sending Html5 SSE to specific clients
Jun 17, 2012 12:38 PM|LINK
@ haider.ali
¿ then what do you need ?
also, what have you tried?
perhaps you could show us your current relevant code snippets?
it appears to me that you've already solved your own problem ...
example: add a column to your user database that identifies your "specific users" -- in pseudo code:
if sql_user_type == "specific", enable display of some_server_evernt
g.
haider.ali
0 Points
4 Posts
Re: Sending Html5 SSE to specific clients
Jun 17, 2012 01:08 PM|LINK
Here is the Default.aspx file <script type="text/javascript"> window.onload = function () { if (window.EventSource == undefined) { document.getElementById('targetDiv').innerHTML = "Your browser doesn't support Server Side Events."; } var source = new EventSource('SSEHandler.aspx'); source.onopen = function (event) { document.getElementById('targetDiv').innerHTML += 'Connection Opened.<br>'; }; source.onerror = function (event) { if (event.eventPhase == EventSource.CLOSED) { document.getElementById('targetDiv').innerHTML += 'Connection Closed.<br>'; } }; source.onmessage = function (event) { $("#targetDiv").append(event); }; } </script> <div id="targetDiv"> </div>and here is 'SSEHandler.aspx' cs
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "text/event-stream";
while (true)
{
if(checksomecondition())
{
Response.Write("hello");
Response.Flush();
}
i++;
System.Threading.Thread.Sleep(3000);
}
}
this code push the event to client if certain condition is satisfied , i have username in session , what i want is to send the event to that user
gerrylowry
All-Star
20513 Points
5712 Posts
Re: Sending Html5 SSE to specific clients
Jun 17, 2012 01:44 PM|LINK
@ haider.ali
¿ which event ? why?????
N.B.: you can not send the "event" ... you must handle the "event" at your server.
what you can do is to set a value such as a string variabler in your event handler to pass whatever meaningful information your end user requires ... in pseudo code:
// in event handler
String myEventMessage = " ... whatever you want your end user to know ... ";
g.
Allen Li - M...
Star
10411 Points
1196 Posts
Re: Sending Html5 SSE to specific clients
Jun 18, 2012 06:55 AM|LINK
Hi, you can use Web service to check Session variables and write the result to client, please refer to my following reply:
http://forums.asp.net/p/1772368/4846649.aspx/1?Re+net+Session+Variable+in+Javascript
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework