*

Carlos Carcamo

  • ****
  • 105 posts
  • LaKompra.com
Real Time Chat
« on: February 28, 2017, 07:23:49 PM »
Hey guys.

Today I want to start a discussion about real-time chat for Instant Messenger, this is one incredible and essential plugins that we really need to have.

I don't know if is in progress the option to made the chat real time, but I want to share some of my experiments, I don't have experience in PHP socket but I have an easy idea that may work.

I have 2 ideas to make the chat real-time without a lot of code,

1 - Reload the chat div showing new messages (without reloading the entire page), using javascript using setInterval(function()

2 - Using Jquery to submit and clear the form after clicking on "Send message"

I already try the reload chat process, but no luck.

Code: [Select]
<script type="text/javascript">
 
function loadlink(){
    $('#links').load('',function () {
         $(this).unwrap();
    });
}

loadlink(); // This will run on page load
setInterval(function(){
    loadlink() // this will run after every 5 seconds
}, 5000);
</script>


I put the #links with one of the divs for example <div class="im-table im-messages im-body"> line 108 in messages.php and the final code is <div class="im-table im-messages im-body" id="links">

Is reloading, but is not in a good way.

Any of you guys have an advice or can we work together on this, maybe you guys have a better idea to do this in an easy way, or if you know which DIV is a better option to reload, or maybe message.php is not the correct file.

I install the example in this tutorial https://css-tricks.com/jquery-php-chat/ and is working great.

In order to periodically Checking for New Messages, they are using
Quote
<body onload="setInterval('chat.update()', 1000)">
, but in this case I dont know which funtions request to onload.

Thank you any idea will be great
LaKompra.com

*

MB Themes

Re: Real Time Chat
« Reply #1 on: February 28, 2017, 09:25:43 PM »
@Carlos
I already though about this idea, but there comes a lot of problem and I am not sure if all of them can be handled in plugin.
Generally if you look i.e. on zopim that provides also way of chat, there are whole teams that develop these apps. If you consider what would be time required for development to make real-time chat as stable as possible, it could take years....
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

oscman

  • ****
  • 227 posts
Re: Real Time Chat
« Reply #2 on: March 13, 2017, 06:09:36 AM »
This would kill servers for sites that has many users... i have xeon e5 with 100gb ram and ssd and osclass is already killing my server.
You should check cometchat its fantastic and they offer integration.