|
Post by Doan the Nado on Jul 9, 2006 22:44:36 GMT -5
Update: See this post at the end of this thread. I have made a major overhaul to the chat system, and good portion of the information in this post is no longer true. The update on how the system works (in comparison to how it used to) is in this post. I have finally built something this place has been lacking for a long time. It took a lot of trial-and-error (and frustration), but we now have a chat. I wrote the code entirely on my own, and it all resides in www.doanthenado.com/chat/To call it "the code" is actually a bit misleading, because the beauty of it is that there is very little javascript at all. It is simply a double-nested iframe. The first iframe is chat-window.cgi. This frame contains another iframe (I'll explain) and the Send form where you type in your messages. The iframe that is within chat-window.cgi is called chat.html. This simply contains the text that is seen within the box, along with instructions that tell it to refresh every 15 seconds. Now the real work happens when you actually send a message. The message is sent to chat-post.cgi, where a perl (that's a programming language in case you haven't heard of it) script takes what you are posting and modifies the chat.html file. It removes the oldest message and adds yours to the file. And that's all there is to it! (Although figuring out how to do all this is a different story entirely.) If you have any comments or questions for me, or more importantly, and issues with your browser and the chat program, feel free to let me know. Known Issues:The box is skinny. I know this, and it's because I plan on integrating it into a table at the top of the board which appears on every page. In Internet Explorer, the page doesn't refresh when a post is made. I'm working on finding a solution to this problem. In the meantime, you could get a browser like Firefox (just do a Google search). Once you get used to it, you'll love it! It needs X feature. I plan on adding features after I fix current problems, and after I get it integrated so that it appears on every page seamlessly. Features I plan to add:Some UBBC support (font-formatting tags such as b, u, & i, and urls). Chat username is same color as username on message board. Pop-up window feature so that you can chat in a large window if desired. Smileys. Any other good ideas that people give me:
|
|
|
Post by realitybites on Jul 9, 2006 23:03:47 GMT -5
Its great, Comments:Very nice, works in FireFox only(obviously not working in IE) I think its a little small, but when you get that table it should be fine. What I think it should have:Ability to use UBBC, have a dropdown smiley box or have a index next to the chat showing how to make each smiley with Text, e.g. " "= Kudos Doan, for giving us a great feature!
|
|
|
Post by Doan the Nado on Jul 9, 2006 23:08:57 GMT -5
It works in IE, it's just a bit more cumbersome. As for the rest, those features will come eventually.
|
|
|
Post by realitybites on Jul 9, 2006 23:11:09 GMT -5
Glad to hear it
|
|
|
Post by Rodak on Jul 11, 2006 16:38:06 GMT -5
It interferes with my usual keystroke patterns! I hate using a mouse. I use the keyboard for as much as possible. even when inconvenient! It comes from being a left handed dyslexic, Or Something! I think. But Yeah... Chat. Never did much for me. I HATE Internet Acronyms! But it's Very Impressive! Pretty Hoopy Work, There! Well Done. Here, Have a piece of hand drawn animation for no good reason! I don't recall if I ever posted that here. On dial up back up again, so wont check! Oy...
|
|
|
Post by realitybites on Jul 11, 2006 17:41:49 GMT -5
That is a very weird and funny animation Rodak, ;D
|
|
|
Post by Doan the Nado on Jul 11, 2006 19:49:30 GMT -5
Oh, I'm sorry about that. There will be some issues with it as I am getting it integrated. Once I have everything working smoothly, I will work on adding options for individual users, including things like "hide chat" or "do not place focus in chat box".
Other than that, I don't know what else I can do. That's why I created this post to learn of any issues that you are having with the program.
If you are having a problem, please report it as thoroughly as possible, and I will attempt to do something about it.
|
|
|
Post by Rodak on Jul 12, 2006 5:00:29 GMT -5
There is no problem.
I can adapt.
What happens is that when logging in I usually press tab after entering my user name.
This does not take me to the next input box anymore (password) but rather to the chat thingy!
I can adapt, but it'll take time.
Let me know if you plan on changing it back and I'll stop trying to change my habits and just wait!
It's not a big deal at all.
I also noticed that when trying to read the Chat Box it refreshes and the old posts can not possibly be read!
What else...
Putting the "Must be logged in to chat" note "outside the box" would allow more room in the frame for actual chat content.
That's about it.
Still an impressive use of the resources you have!
Peace.
|
|
|
Post by Doan the Nado on Jul 12, 2006 23:51:55 GMT -5
I just completely changed the way the chat is run. Okay, so I didn't completely change it, but I changed enough stuff to make it so that the interaction between your browser and the server for my website is completely different. Before, there was an instruction in the header of the chat page (the scrolling window) which instructed your browser to refresh that little page periodically. This had a few drawbacks: - It was impossible to stop the refreshes by hitting Stop.
- Every 15 seconds, the server was sending you a page of 50 messages, even though there may have been no new messages to send. Basically, we were receiving the same info over and over again.
- Sometimes after posting, your message wouldn't show up until the next refresh. This seemed to happen more often in IE.
- There was no simple way to maintain your location in the chat window: if you had scrolled up to read messages, you would be all the way at the bottom again after a refresh.
Needless to say, with all these problems, there were a few changes which needed to be made. After a lot of research, I came up with some answers that seemed quite suitable. Now, instead of your browser receiving an instruction to refresh periodically, the connection is simply never terminated. If you notice that the page constantly says Opening or Loading, that is completely normal. It is because while you are on the page, there is a process constantly running on my website server. It checks the last modified date on the chat.html file every 5 seconds. If the file has been updated, it sends you the last line of the updated file. Only the last line. Otherwise, there is nothing to send your browser, but if you go too long without sending any info to the browser (how long is too long depends on the configuration of the server and your browser), the connection will be closed, and the server will no longer be able to update your page. So when there is nothing to send, the server simply sends back a single null character (ascii 0), which is not displayed anyways. In summary, instead of your browser requesting a 3KB page every 15 seconds, the server keeps a constant connection by sending 1 byte every 5 seconds. This means that this new method uses 0.1% of the bandwidth that the previous one was. Also, every time a message is sent back to you now, I can send back a Javascript command to scroll by a certain number of pixels. Right now I have it set at 150, but this is something that I will need to play with in order to get right. Current issues: IE seems a bit buggy when initially loading the chat box, as it does not scroll all the way to the bottom as it should. Incremental scrolling (when messages are received) seems to be working okay, though. Update: I just fixed the above issue. It turns out that IE was trying to scroll before the content was completely loaded. I added a 0.1 second delay between printing the content and scrolling, and then it worked fine. If anyone else has a similar problem, be sure to let me know, and I can try lengthening the delay a bit.
|
|
|
Post by Rodak on Jul 14, 2006 15:55:58 GMT -5
It's Official. I am from Another Planet. I have repeatedly tried to make sense of the words and stuff in the chat box, but most of it is unintelligible!! I have no clue about all those acronyms! I once said it gave me Acrophobia... but now I like Acronymphophobia better! Gets the whole word in there. Something Lost on the Chat Crowd. Sorry Folks, I am only able to understand English and it is just too much work to try and read that stuff! I'm glad You guys like it, and Doan did some Great Work on it. Have Fun! I'll see you out here. Peace.
|
|
|
Post by The Final Rune on Jul 25, 2006 9:47:41 GMT -5
[white]I don't see the chat box on my comp. Instead I have black text that reads "That won't work" I do how ever see it on IE when I'm at work, which makes me kind of glad that I don't see it here at home. Why does it keep track of every single message that posted? Shouldn't it drop any that are more than a certain amoutn of time old? It was really annoying to have it reload every single message everytime I went back to the home page.[/white]
|
|
|
Post by Doan the Nado on Jul 25, 2006 17:26:16 GMT -5
[white]I don't see the chat box on my comp. Instead I have black text that reads "That won't work" I do how ever see it on IE when I'm at work, which makes me kind of glad that I don't see it here at home. [/white] That means that your browser does not give REFERRER_URL information. This is important to the functioning of the chat, because it serves to ensure that the window is only displayed from this message board and that no one is able to Chat as someone other than who they are on ProBoards. If your browser is in a really high security setting or simply does not report REFERRER_URL information to sites that are being visited, then chat will not work for you. It only keeps track of the last 50 messages, so what you are suggesting should be done actually is done. Any messages older than the last 50 are dropped. Also, if each message is on average 50 characters, with each character taking up a single byte, then loading all of the last 50 messages will be 2500 bytes, or approximately 2.5KB. It is true that there is also undisplayed markup on each post, but all told, to load everything, it will not be more than 6-8 KB. By comparison, EACH banner on the main page is 10KB. I really don't think loading the text should be an issue. If it seems like the page never stops loading, that is completely normal, because for the chat to be able to continually update when someone sends a new message, the connection between your browser and the server remains open and characters are constantly being sent to your browser (1 byte every 5 seconds if there is no message to send, or the next message if there is one to send). The alternative to this is for your browser to refresh the chat every so often (the way I originally implemented it), but this leads to much higher bandwidth usage and other problems.
|
|
|
Post by reynolds1203 on Nov 30, 2006 22:56:23 GMT -5
On my home computer i can not see the chatbox, the post bost and the send button are visible and i can even send messages but the chat box is white and empty, i don't seen any text. any idea whats wrong? do i need to download something, i tried changing the security level on my browser but it didn't fix it either, i don;t know, just wondering
|
|
|
Post by Doan the Nado on Dec 1, 2006 0:38:20 GMT -5
No, it's likely a problem with the way my chat box is designed combined with the display properties of your browser. That is, the chat thing works by constantly sending data to the browser so that when a new message is posted, it will show up on your computer. The problem is that some browsers may not display anything until the whole page is received. In that case, you probably won't be able to see the chat unless you either hit 'Stop' in your browser, or perhaps not at all. It's an unfortunate limitation of the current design, and at some point I plan on redoing the whole thing (including perhaps even writing my own message board program), but this quarter has been ridiculously busy, and I haven't had time for much of anything other than grading and schoolwork.
|
|
|
Post by realitybites on Dec 18, 2006 12:24:30 GMT -5
Hmmm are you using a MySQL database doan? If so, maybe Reynolds computer doesn't support it.
|
|
|
Post by vespuleth on Dec 18, 2006 20:17:42 GMT -5
no.
|
|
|
Post by thetruecoolness on Dec 23, 2006 3:07:05 GMT -5
Yeah there is no need to use a DB for a chat, a well made binary file should do the trick. The one I made has two binary files for the message logs and switches them out as one becomes full, this way you don't have to worry about where a new message will be, it's always at the "end" of the current log being written to. This also makes writes pretty fast as the files never change size (this can become very slow depending on the OS and filesystem).
So unless you just like putting unnecessary stress on your DB Server I would not use a DB for a chat. I just use it for user name data, though even that could be a binary file easily, or even a cleverly delimited text file.
As for the constantly sending data, really one check every second should suffice. Not sure if it's because my chat uses Ajax or not, but it doesn't look like it's constantly refreshing in the browser like the one you wrote does. Might have something to do with yours being in an iframe as well. Does yours also cause HTTP requests to spike, or does yours do it in a way that it doesn't use HTTP requests? I know having an AJAX chat makes your access logs become much bigger, even with only a few people using it.
Of course I would imagine mine sends much less data as it only sends the messages that haven't been received since the last check, so a lot of times it sends nothing (it just updates the HTML of the chat page for the chat area). Problem with that being if the user hits refresh he doesn't get too see the messages before he hit refresh, but it sure cuts down on the data sent. Though I could trick it into doing that by resetting the users SESSION variable for last check on a refresh of the page.
|
|
|
Post by realitybites on Dec 23, 2006 10:13:33 GMT -5
Ah, the only reason I use a database for now is cause im still learning how to do it with binary code, with a simple file. I will change it once I learn how to do that.
|
|
|
Post by Doan the Nado on Dec 25, 2006 2:39:27 GMT -5
I don't really see any reason to use a binary file when a simple text file will suffice just as well. Right now, I admit that it is not set up in the most straightforward manner, but I was forced to jump through some hoops because of:
1) The message board is by ProBoards, so all I can add is simple HTML (including Javascript and CSS) to the page. I cannot have CGI scripts or anything on the ProBoards side, so I use an iframe to a personal website where I can have some scripts running.
2) At the time I created it, I did not have the capability to host my own content, so all testing/editing of scripts had to be done through ftp/http access to my host (the host of doanthenado.com). This limited me a bit in what I was able to use.
I would like to point out, as I have numerous times, that the bandwidth used by my method is very low. Every few seconds, the server sends a single byte of data to the client (the person with their webpage open). If a new message gets added, that message gets sent instead of the byte. I admit that AJAX is a better approach, but I do not think that it will accomplish a whole lot that isn't already accomplished by what I have. There are a few issues that we all know about, and when I redo the entire site/message board, the chat system will be all-new as well, and better integrated. Until that time, I think it best to keep it as it is, since it pretty much works well for almost everyone.
As for using a database, I suppose that might help with synchronization to ensure that writes are always consistent, but it is really overkill, and I can't imagine that using a database is any easier than using a simple file would be. I mean, all my program does is open a file, read in all the lines, throw out the oldest line, append the newest line (with some HTML added in), and print everything back to the original file. Pretty simple if you ask me.
|
|
|
Post by realitybites on Dec 25, 2006 2:47:15 GMT -5
Yeah, but to each his own. One question though....Why, if I open a new window of the main page, that chat doesn't show in the second window?
|
|
|
Post by Doan the Nado on Dec 25, 2006 3:50:56 GMT -5
That's something with the way that Firefox works, I think. It is very strange behavior, I agree.
|
|
|
Post by realitybites on Dec 27, 2006 15:35:25 GMT -5
It Doesn't work for me anymore.....
|
|
|
Post by thetruecoolness on Dec 30, 2006 0:15:04 GMT -5
Well the binary file is for a couple of reasons, mainly because mine works slightly different than yours on updating. If PHP had consistent support for float values written as binaries it might save some room, but it would be pretty negligible (since the timestamp needs to be a float since PHP does not have a Long Int). The main reason I do it is so I don't have to read the entire file when checking for messages, I can just figure out where a message is, and only read the new ones. Also it's a little faster to preallocate a file and then use random access to fill it in. So while I could use a regular text file it doesn't give as consistent results when trying to scan to the 'end' of the file to write in a new message. This also allows the file to always be the same size (though just a size check on the message will allow this as well). Also my chat only checks every second for all new messages since the last check, instead of constantly checking (since more than one might be received in a second).
Of course any performance gain on not having to read or write out the whole file on each change depends a lot on the OS's caching behavior, and how smart it is, and how often it flushes buffers.
But of course your chat works very well, except for crashing certain extensions (though that's hardly your fault). Still odd it's the only site that does it. But if it's not broke don't fix it.
As for testing, you could have always set up a HTTP server on your computer that just accepts localhost connections. That's what I do to test out things before putting them up on hosting now. So it's nice and secure, though it's hard to test a high amount of clients, through using different browsers you can test a few concurrent ones.
|
|
|
Post by Drew on Dec 19, 2008 21:33:10 GMT -5
This may be bumping an old thread, but Doan if youd like and if any of the members would want this back again, I can host the files, and can configure it if need be. Just tell me if you would like so, as well as other members as well, its nice to have for the people that are actually online, they can just leave a quick little message or chat. Anyway its totally up to you.
|
|
nate
RPG Maker-in-Training
Posts: 28
|
Post by nate on Jan 25, 2009 21:55:39 GMT -5
no chat?
|
|