a simple chat system

renejimsoler96

New Member
Messages
2
Reaction score
0
Points
0
i'm planning to create a simple public chat system for our site.

since there is a forbidden way to do it, the resource hog way, my plan is having two frames in a window, frame 1 will be displaying the messages, it refreshes for every 3 seconds, and frame 2 will display the input for message...

is that a good plan?

i need some suggestion, because, it's my first time to create a chat system...

thanks in advance...
 

phoenixreviews

New Member
Messages
34
Reaction score
0
Points
0
i'm planning to create a simple public chat system for our site.

since there is a forbidden way to do it, the resource hog way, my plan is having two frames in a window, frame 1 will be displaying the messages, it refreshes for every 3 seconds, and frame 2 will display the input for message...

is that a good plan?

i need some suggestion, because, it's my first time to create a chat system...

thanks in advance...


This is one way, which will work but will also result in flickering in the first window. Another method I would consider using is AJAX. Make the whole thing one frame, and do everything with javascript. You would have two main javascript methods:

  • Update function, called every 3 seconds. Requests a list of all messages received in the last few seconds, and adds these messages to the div on-screen
  • Submit function, called when the user sends a message. Submits the message to the server, and calls the first function above to refresh the screen.

This way will also cut down on resources, as you only have to fetch the most recent messages instead of the whole list every time.

Cheers,

David
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
This is one way, which will work but will also result in flickering in the first window. Another method I would consider using is AJAX. Make the whole thing one frame, and do everything with javascript. You would have two main javascript methods:
Update function, called every 3 seconds. Requests a list of all messages received in the last few seconds, and adds these messages to the div on-screen
Submit function, called when the user sends a message. Submits the message to the server, and calls the first function above to refresh the screen.

This way will also cut down on resources, as you only have to fetch the most recent messages instead of the whole list every time.

Cheers,

David
That was exactly the type of system he was trying to avoid as that would count as a shoutbox under the terms of service and would therefore result in a suspension. The initial idea would, as you say, also be a resource hog and would likely also be counted as a shoutbox.
The simplest way to avoid this clause is to defer the hosting of the chat-room to an external server: you could either run an IRC widget such as Mibbit or use an external chat-room host. As long as the chat system is not running it's database on the x10 servers then you should be fine.
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
my plan is having two frames in a window, frame 1 will be displaying the messages, it refreshes for every 3 seconds, and frame 2 will display the input for message...

That idea is actually more resource-intensive than the equivalent AJAX/AJAJ application with a 3-second update schedule. Everything at the model level is done more-or-less the same way, but you have to check more messages and write more to the web client than you would if you were just looking for messages newer than the last check and writing compact JSON or XML because you have to recreate the entire chat record page on every update.
 

phoenixreviews

New Member
Messages
34
Reaction score
0
Points
0
That idea is actually more resource-intensive than the equivalent AJAX/AJAJ application with a 3-second update schedule.
Very true. I hadn't been aware of the TOS restriction on shoutboxes, but taking that into consideration the only way to implement this would be to host the chat on an external site, and just include an iframe in your site with the external chat widget.
 
Top