PDA

View Full Version : i have problem with Notification


bmwmpower
08-12-2003, 09:04 AM
I have chat module and my chat depend on text file
What I want is when any user type new line if my chat window minimize i need the window make notification or focus
Because this notification or focus means that is user chatting or write in the chat window
I need any idea or any help sorry my English is bore

raf
08-12-2003, 11:14 AM
Not sure i understood that.

Do you wan't to notify all visitors when someone types in something in the chatbox?
ASP is a server side language and it only sends a response (message to the client) when it got a request (client requesting a page). This means that the client needs to reload the page. You could do that autimatically by using some javascript that automatically reloads the page (or one limited sized frame) each second or each five seconds or so. But this generates a lott of unnescecary trafic. So server side languages are not ideal for chatting-app's.

You better use an IRC channel for that. More info and software here
www.irchelp.org

bmwmpower
08-13-2003, 11:06 AM
yes raf i need

i wan't to notify all visitors when someone types in something in the chatbox?
yes in my code i make autimatically reload ( refresh ) every each five seconds
but how i can make this notify

this is my code when user send msg

If Request.Form("Add") = "TRUE" Then
file = file & "<FONT SIZE=2 Color=#000000 FACE='Verdana,Arial'><b>" & name & "</b><small>("& date &" - "& timeaa &" GMT)</small>:</FONT>" & Request("Msg") & "<br>"

Set outStream = fileObject.CreateTextFile(textFile,True)
outStream.WriteLine(file)
Set outStream = Nothing
End If

what i need is when the user send this Msg i need notify all visitors bye ( fouce window or any notify )


can u help me or if u can give me example






can u give me example

raf
08-13-2003, 12:10 PM
well, i never made anything like it coase reloading the pages for each user each 5 seconds must be quite a resource eater + it keeps all users sessions alive, even if they left there machine alone (which means you should implement your own sessionmanagement where they can't stay on the same page for X minutes or work with framepages (see below)) and it envolves to much db-trafic to check for new messages etc OR you could use the application-object. But ASP is really not the best technologie to do this !
So i can't give tyou an example.

Now, you want to notify these users.
I've got the impression you wan't to open a new window and display some info there.
I think you can best do this with a piece of javascript you include in the page, if a new message was posted. So this javascript would then open an url(with the message in) in a new window. But popups are annoying and lot of people will use a popupkiller so they wount see the messages + people that disable javascrip also miss out on all the fun (the pages wount reload also)

This is what i would do : create a framepage and have only one frame that displays the message, or that displays a link to the message. And just reload this one frame each 5 seconds (not the framepage itself, only the page in one of the frames). This will generate the least trafic and will work with popupkiller-users.
You can do the same with an iframe, i suppose. So each 5 seconds an ASP page is requested. This pages should then check if there were new messages since the last check from that user.
I suppose you're only interested in the last few messages.
So say that we create an applicationvariable that is an array, that contains the poster + date-time-value of the messagesubmit + the message (or an url to the message) of the last 10 entry's as a pipedelimited string (poster|date|message).
So you could then do something like

your reload code
dim i, locked, arrdata
locked = application("entrys")
i = 0
response.write(<table>
do while i <= 9
arrdata=split(locked(i), "|", -1,1)
response.write("<tr><td>arrdata(0)</td><td>&nbsp;&nbsp;arrdata(1)</td> <td>&nbsp;&nbsp;arrdata(2)</td></tr>
i = i+1
loop
response.write(</table>

to display the last 10 entrys
Note : the second and third cell starts with 2 spaces but they get transformed here.

If you run sessionchecks (for instance when they need to log in or if you use sessionidentifiers etc) -->You should make sure that the framepage is an html-page (.htm or .html extension). This way, the server will create a different session for each frame. If the client leaves his machine alone, the message-frame's session will be kept alive, buth the other frame (your normal page you have now) will timout. I the user (or another user) hits a link or reloads the page, his session will be destroyed and you can redirect him to the homepage (if you run a session-check on top of your pages)