+ Reply to Thread
Results 1 to 5 of 5

Thread: a simple chat system

  1. #1
    renejimsoler96 is offline x10Hosting Member renejimsoler96 is an unknown quantity at this point
    Join Date
    Sep 2010
    Posts
    2

    Question a simple chat system

    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...

  2. #2
    phoenixreviews's Avatar
    phoenixreviews is offline x10Hosting Member phoenixreviews is an unknown quantity at this point
    Join Date
    Apr 2010
    Location
    Australia
    Posts
    34

    Re: a simple chat system

    Quote Originally Posted by renejimsoler96 View Post
    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

  3. #3
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: a simple chat system

    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.

  4. #4
    essellar's Avatar
    essellar is offline Community Advocate essellar has a spectacular aura about
    Join Date
    Feb 2010
    Location
    Toronto, Ontario, CA
    Posts
    1,153

    Re: a simple chat system

    Quote Originally Posted by renejimsoler96 View Post
    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.
    “Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
    "It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)

  5. #5
    phoenixreviews's Avatar
    phoenixreviews is offline x10Hosting Member phoenixreviews is an unknown quantity at this point
    Join Date
    Apr 2010
    Location
    Australia
    Posts
    34

    Re: a simple chat system

    Quote Originally Posted by essellar View Post
    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.

+ Reply to Thread

Similar Threads

  1. Replies: 4
    Last Post: 07-29-2009, 09:00 AM
  2. Replies: 2
    Last Post: 09-22-2008, 09:52 PM
  3. One update on our chat system.. (IRC)
    By Russ in forum Free Hosting
    Replies: 9
    Last Post: 02-20-2008, 05:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers