Help Center Live Community
April 24, 2014, 12:26:56 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1] 2   Go Down
  Print  
Author Topic: Multiple operators starting same chat  (Read 16678 times)
BrianP
Not too much to say...
*
Offline Offline

Posts: 30


« on: May 18, 2009, 08:48:38 PM »

I am running HCL 2. 1. 7 on a Feodra 8 machine with apache 1. 3. 41 and PHP 5. 2. 6.   I have a department setup with 2 operators read to accept chats (one with priority 0 and one with priority 1).   Using 3 machines to test, I log in to two of them for operators, and on the third machine I start a chat.

What I am seeing is this.   When the chant request comes it, it appears on the Live Help monitor for the first operator (the one with priority 0).   If I wait 30 seconds, the chat request will appear on the second operator (with priority 1).   This is what I expected.   BUT, the chat request does not clear off first operator's monitor.

If the second operator starts the chat, the chat starts.   But the first operator can still join the chat (which becomes a conference).   Worse, if the first operator declines it, it will close the chat opened by the second operator!

The same thing happens if the 30 seconds expires, so it appears on operator 2's monitor but operator 1 grabs it.   I have a 3 way chat going on, but the client sees the same name for the operator.

Make sense?  I expected as HCL moved through the available operators, it will disable the previous operator.   Or at least prevent someone else from joining and existing chat.

I have tried this on combinations of the following 3 browsers.   I have done the aardvark changed for firefox:
Firefox 3. 0. 10 on Fedora 8
IE7 on WinXP
Seamonkey 1. 1. 12 on Fedora 8

Any thoughts? This seems wrong to me. . . .

- brian
Logged
SpenserJ
Moderator
HCL Regular
*****
Offline Offline

Posts: 179

Some helpful guy


WWW
« Reply #1 on: May 19, 2009, 01:27:52 AM »

Thank you for such an in-depth post, it truly makes life easier!

Personally, I find it to be sensible for it to leave the chat available for priority-0 operators yet also show it for priority-1 operators, however after the chat is joined it SHOULD be removed from both screens. I have a feeling this is a bug with the core of the current release and as such there isn't really a way around it.  All I can really suggest is that you make sure your operators know to not decline a chat if someone is in it already, and if they do join a chat with someone in it already, just close the window.

Sorry about that, hopefully V3 will be out soon and that will fix this

Spenser
Logged

I am NOT a developer for HelpCenterLive. I am just trying to help out anyone that has issues. If you have a problem, check the list of fixes and then create a new topic
BrianP
Not too much to say...
*
Offline Offline

Posts: 30


« Reply #2 on: May 19, 2009, 06:48:33 PM »

Thank you for such an in-depth post, it truly makes life easier!

Personally, I find it to be sensible for it to leave the chat available for priority-0 operators yet also show it for priority-1 operators, however after the chat is joined it SHOULD be removed from both screens. I have a feeling this is a bug with the core of the current release and as such there isn't really a way around it.

The more I think about it, the more I agree with you on allowing a higher priority user to still accept the chat.

But, here is where it gets interesting.  I wonder if there is just a refresh problem.

I am testing right now.  My client (asking for help) is IE7 on WinXP.  Priority 0 operator is on Seamonkey 1. 1. 12 on Fedora 8 and Priority 1 operator is on Firefox 3. 0. 10 on Fedora 8.  So, the request comes in.  30 seconds after the request, it appears on pri1's screen.  If I accept on pri0, pri1 still shows the request (the original problem).

But, force a refresh of the screen on pri1 (F5 in firefox).  The message to accept the request is gone!  In fact, I noticed that even after the chat is complete, it never cleans up the other windows to show the chat ended.  I have even seen this with a single operator and the chat request times out.

So, is there a different set of refresh code being called when a request is pending versus when there are no requests pending?  Anyone know some php (perl, java, c++ and I would be all over it).....

- brian
Logged
SpenserJ
Moderator
HCL Regular
*****
Offline Offline

Posts: 179

Some helpful guy


WWW
« Reply #3 on: May 19, 2009, 07:59:04 PM »

I do know PHP and Javascript myself, and I would totally figure out how to fix it, but I have no time to right now Sad I am actually hacking together a custom solution for my client, as many of the employees use macs, and HCL doesn't support macs right now Sad One thing you might be able to do is find the layout code (it is a smarty template) and just throw in something like
Code:
<meta http-equiv="refresh" content="30" />

into the header. It is a bit of a hack, but it will force the page to refresh every 30 seconds.

Spenser
Logged

I am NOT a developer for HelpCenterLive. I am just trying to help out anyone that has issues. If you have a problem, check the list of fixes and then create a new topic
BrianP
Not too much to say...
*
Offline Offline

Posts: 30


« Reply #4 on: May 19, 2009, 08:15:42 PM »

however after the chat is joined it SHOULD be removed from both screens. I have a feeling this is a bug with the core of the current release and as such there isn't really a way around it.

At the moment my boss is way more concerned with this problem than the refresh problem.  Since a complete refresh will make the chat request go away, in theory a check could be made to prevent the second operator from starting the chat altogether.  So, I will see if I can understand enough PHP to add a check to the accept processing to prevent the connection to the chat.  I will probably also modify the template to remove the 'decline' link to prevent the chat from closing if another operator has answered it and to prevent the round robin queuing of the operators (which is aborted if anyone in the queue hits decline).

if anyone has an idea of where I should look to add my check (or any information on the database layout) that would be helpful.

- brian
Logged
SpenserJ
Moderator
HCL Regular
*****
Offline Offline

Posts: 179

Some helpful guy


WWW
« Reply #5 on: May 19, 2009, 08:48:30 PM »

Well, if you check in hcl/live/chat you will find a couple different files you could add it in, my guess is either display.php, index.php (which I can't load for some reason, so not sure what is in it), or main.php. You could also add a check in a couple of the classes (hcl/classes), but I have yet to figure out which ones really... Just took a quick 5-10 minute scan through the files. The check only needs to consist of something like
Code:
if ($GLOBALS['live']->operatorid($GLOBALS['live']->chatid()) != null) {
    die ('Someone is chatting already!');
}

Didn't test that, and some of the calls are probably wrong, but you can find operatorid in the chat.php class, and running that would tell you if someone had joined the chat already. I couldn't find where the chat was actually accepted in the time I took to check though, so read around a bit.

Spenser
Logged

I am NOT a developer for HelpCenterLive. I am just trying to help out anyone that has issues. If you have a problem, check the list of fixes and then create a new topic
BrianP
Not too much to say...
*
Offline Offline

Posts: 30


« Reply #6 on: May 20, 2009, 05:44:47 PM »

Holy complicated batman!

Here is what I have found so far.  When the chat request comes in, an entry into sessions is writing like this
| id  | chatid | assignid | departmentid | operatorid | nick      | alert    | timeo      | timeg      | typeo | typeg | transfer |
+-----+--------+----------+--------------+------------+-----------+----------+------------+------------+-------+-------+----------+
| 111 |     26 |       25 |            5 |          5 | win test  | received | 1242837174 | 1242837174 |     0 |     0 |          |
+-----+--------+----------+--------------+------------+-----------+----------+------------+------------+-------+-------+----------+

Once the chat is accepted, the row is updated to:
| 111 |     26 |       25 |            5 |          5 | win test  | accept | 1242837206 | 1242837205 |     0 |     0 |          |

So, I can use this to tell if the chat is already in progress!

But, I can't just change live/chat/main.php as that is called every time the pages reload and I only want to check this when the chat starts.  The same page is used by the operator and the client, so I need to make sure I am only affecting the client also.  Not to mention I need to make sure I only affect the correct operator.  wowsers....

I think the better solution would be to affect this between the click of 'accept' and the display of main.php, but I haven't tracked this down yet (which is a bit of a pain when you don't know php and barely know javascript Smiley

Still looking...
-brian
Logged
SpenserJ
Moderator
HCL Regular
*****
Offline Offline

Posts: 179

Some helpful guy


WWW
« Reply #7 on: May 20, 2009, 07:57:19 PM »

Good to see you making a bit of progress... I am assuming there would be a function in one of the classes to handle accepting a chat request, so if we can find that, dropping a call in there should be simple, or finding the page that is called by clicking the accept button. I might look into it a bit more if I have time

Spenser
Logged

I am NOT a developer for HelpCenterLive. I am just trying to help out anyone that has issues. If you have a problem, check the list of fixes and then create a new topic
BrianP
Not too much to say...
*
Offline Offline

Posts: 30


« Reply #8 on: May 20, 2009, 08:21:09 PM »

Good to see you making a bit of progress... I am assuming there would be a function in one of the classes to handle accepting a chat request, so if we can find that, dropping a call in there should be simple, or finding the page that is called by clicking the accept button. I might look into it a bit more if I have time

I believe I have found where this needs to be done.  In class/js/monitor.php is the code that is executed when the accept link is clicked.  But I don't have a clue how to do php and javascript together and am now just beating my head against the wall.  (using class/js/nomarl/monitor.php for readability):

Code:
        this.accept = function(id, chatid, type)
        {
            this.request = false;
            MonitorConnection2.add('accept_'+type, '');
            MonitorConnection2.add('id', id);
            MonitorConnection2.add('chatid', chatid);
            MonitorConnection2.add('time', Misc.epoch());
            MonitorConnection2.send('<?php echo($GLOBALS['conf']['url']); ?>/admin/monitor/response.php', 'Monitor.reset()', 'reset');
            switch (type) {
                case 'chat':
                    window.open('<?php echo($GLOBALS['conf']['url']); ?>/live/chat/main.php?admin&chatid='+chatid, 'chat_'+chatid, 'toolbar=no, status=no, scrollbars=no, resizable=yes, location=no, menubar=no, directories=no, width=<?php echo($GLOBALS['conf']['chat_op_width']); ?>, height=<?php echo($GLOBALS['conf']['chat_op_height']); ?>');
                    break;
                case 'transfer':
                    window.open('<?php echo($GLOBALS['conf']['url']); ?>/live/chat/main.php?admin&chatid='+chatid, 'transfer_'+chatid, 'toolbar=no, status=no, scrollbars=no, resizable=yes, location=no, menubar=no, directories=no, width=<?php echo($GLOBALS['conf']['chat_op_width']); ?>, height=<?php echo($GLOBALS['conf']['chat_op_height']); ?>');
                    break;
                case 'opchat':
                    window.open('<?php echo($GLOBALS['conf']['url']); ?>/live/chat/main.php?admin&opchat&chatid='+chatid, 'operator_'+chatid, 'toolbar=no, status=no, scrollbars=no, resizable=yes, location=no, menubar=no, directories=no, width=<?php echo($GLOBALS['conf']['opchat_width']); ?>, height=<?php echo($GLOBALS['conf']['opchat_height']); ?>');
                    break;
            }
        }

Here is where the windows are opened for the actually chat.  So, I figure is I do a query against the DB before the opening a windows, so I changed it to this:
Code:
        this.accept = function(id, chatid, type)
        {
query2 = 'SELECT * FROM `sessions` WHERE `chatid`="' + chatid + '" and `alert`="accept" and `alert`;

<?php if (!$GLOBALS['db']->query($query2)) { ?>

            this.request = false;
            MonitorConnection2.add('accept_'+type, '');
            MonitorConnection2.add('id', id);
            MonitorConnection2.add('chatid', chatid);
            MonitorConnection2.add('time', Misc.epoch());
            MonitorConnection2.send('<?php echo($GLOBALS['conf']['url']); ?>/admin/monitor/response.php', 'Monitor.reset()', 'reset');
            switch (type) {
                case 'chat':
                    window.open('<?php echo($GLOBALS['conf']['url']); ?>/live/chat/main.php?admin&chatid='+chatid, 'chat_'+chatid, 'toolbar=no, status=no, scrollbars=no, resizable=yes, location=no, menubar=no, directories=no, width=<?php echo($GLOBALS['conf']['chat_op_width']); ?>, height=<?php echo($GLOBALS['conf']['chat_op_height']); ?>');
                    break;
                case 'transfer':
                    window.open('<?php echo($GLOBALS['conf']['url']); ?>/live/chat/main.php?admin&chatid='+chatid, 'transfer_'+chatid, 'toolbar=no, status=no, scrollbars=no, resizable=yes, location=no, menubar=no, directories=no, width=<?php echo($GLOBALS['conf']['chat_op_width']); ?>, height=<?php echo($GLOBALS['conf']['chat_op_height']); ?>');
                    break;
                case 'opchat':
                    window.open('<?php echo($GLOBALS['conf']['url']); ?>/live/chat/main.php?admin&opchat&chatid='+chatid, 'operator_'+chatid, 'toolbar=no, status=no, scrollbars=no, resizable=yes, location=no, menubar=no, directories=no, width=<?php echo($GLOBALS['conf']['opchat_width']); ?>, height=<?php echo($GLOBALS['conf']['opchat_height']); ?>');
                    break;
            }
        }
<?php } else { ?>
alert("Chat started by another user");
<?php ?>

But this fails (apache doesn't like it).  I tried building the query right in the php line
Code:
<?php if (!$GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `chatid`="' ?> chatid <?php '" and `alert`="accept"')) { ?>
But that is no better.

Anyone help me with the php/javascript part?
Logged
SpenserJ
Moderator
HCL Regular
*****
Offline Offline

Posts: 179

Some helpful guy


WWW
« Reply #9 on: May 20, 2009, 09:18:06 PM »

Making good progress!

Here is where the windows are opened for the actually chat.  So, I figure is I do a query against the DB before the opening a windows, so I changed it to this:

CODE IN HERE

But this fails (apache doesn't like it).  I tried building the query right in the php line
Code:
<?php if (!$GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `chatid`="' ?> chatid <?php '" and `alert`="accept"')) { ?>
But that is no better.

Okay, so what you are basically doing is combining server side code (PHP) with client side code (javascript) and the browser (and apache) can't figure out what you want it to do. You are telling it to run a query on 'SELECT * FROM `sessions` WHERE `chatid`="' and then output the string 'chatid' to the client, and then do something with '" and `alert`="accept"'.

And I was about to give you some code to fix that, but looking at it, you can't actually add that there, as PHP doesn't know what chat we are talking about. So you have to add it on the other side of that request. Meaning we have to edit /live/chat/main.php after all.

Code:
<?php
    
include_once('../../class/include.php');
    
$inc = new Includer();
    
$inc->template();
    
$inc->auth();
    
$inc->operator();
    
$inc->department();
    
$inc->chat();
    
$inc->db();
    
$inc->chat();

    if (
$GLOBALS['chat']->blocked()) {
        
$GLOBALS['template']->assign('text'$GLOBALS['lang']['blocked']);
        
$GLOBALS['template']->display('plain.tpl');
        
$inc->finished();
        exit;
    }

    if (isset(
$_GET['admin'])) {
        
$GLOBALS['template']->assign('admin''true');
    } else {
        
$GLOBALS['template']->assign('admin''false');
    }

    
$GLOBALS['chat']->session(addslashes($_GET['chatid']));
    
$GLOBALS['chat']->assign(addslashes($_GET['chatid']));

    
$GLOBALS['template']->assign('chatid'addslashes($_GET['chatid']));

    if (
$GLOBALS['auth']->operator() && isset($_GET['admin']) && !isset($_GET['opchat'])) {
        
$GLOBALS['db']->query('UPDATE `sessions` SET `typeo`="0" WHERE `chatid`="'.addslashes($_GET['chatid']).'"');
    } else {
        
$GLOBALS['db']->query('UPDATE `sessions` SET `typeg`="0" WHERE `chatid`="'.addslashes($_GET['chatid']).'"');
    }

    if (isset(
$_GET['opchat'])) {
        
$GLOBALS['template']->assign('opchat''true');
        
$GLOBALS['template']->assign('javascript''chat&opchat');
    } else {
        
$GLOBALS['template']->assign('opchat''false');
        
$GLOBALS['template']->assign('javascript''chat');
    }
    
    if (!
$GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `chatid`="'.addslashes($_GET['chatid']).'"')) {
        
$GLOBALS['template']->assign('onload'' onload="Chat.empty();"');
        
$GLOBALS['template']->assign('text'$GLOBALS['lang']['chat_empty']);
    }

    
// Display the output
    
$GLOBALS['template']->display('chat.tpl');
    
    
// do events that need to be done at the end of the file
    
$inc->finished();
?>

So what you want to do is add a check right in here:
Code:
<?php
    
if (isset($_GET['admin'])) {
        
// Add the check here!
        
$GLOBALS['template']->assign('admin''true');
    } else {
        
$GLOBALS['template']->assign('admin''false');
    }
?>

And we can do that with some code that I sent earlier...
Code:
if ($GLOBALS['chat']->operatorid($_GET['chatid']) != null) {
    die ('Someone is chatting already!');
}

Give that a shot and see what it does. It is probably pretty harsh (as it will just throw a one line error message most likely) but it should handle it

Spenser
Logged

I am NOT a developer for HelpCenterLive. I am just trying to help out anyone that has issues. If you have a problem, check the list of fixes and then create a new topic
BrianP
Not too much to say...
*
Offline Offline

Posts: 30


« Reply #10 on: May 21, 2009, 03:02:48 PM »

And we can do that with some code that I sent earlier...
Code:
if ($GLOBALS['chat']->operatorid($_GET['chatid']) != null) {
    die ('Someone is chatting already!');
}

Give that a shot and see what it does. It is probably pretty harsh (as it will just throw a one line error message most likely) but it should handle it

Nope, this doesn't work.  The first operator is getting the message the Someone is chatting already message.  The client still starts the chat, but I have no operator at the other end.  I think the problem is at this point, the database/sessions has already been updated to indicate the chat has been started (I believe by class/monitor.php::chats() but I am not sure who calls that, or the first time the page refreshes it calls this code and hits the check, I can't tell.

Bummer, I thought we were there, I will keep looking, but.....

- brian
Logged
BrianP
Not too much to say...
*
Offline Offline

Posts: 30


« Reply #11 on: May 21, 2009, 03:44:19 PM »

Poking around some more in the database, I notice that the session gets updated when the time expires on the first operator:
Code:
mysql> select * from hcl_sessions;
+-----+--------+----------+--------------+------------+----------+----------+------------+------------+-------+-------+----------+
| id  | chatid | assignid | departmentid | operatorid | nick     | alert    | timeo      | timeg      | typeo | typeg | transfer |
+-----+--------+----------+--------------+------------+----------+----------+------------+------------+-------+-------+----------+
| 140 |     26 |       25 |            5 |          5 | win test | received | 1242915533 | 1242915533 |     0 |     0 |          |
+-----+--------+----------+--------------+------------+----------+----------+------------+------------+-------+-------+----------+
1 row in set (0.00 sec)


mysql> select * from hcl_sessions;
+-----+--------+----------+--------------+------------+----------+---------+------------+------------+-------+-------+----------+
| id  | chatid | assignid | departmentid | operatorid | nick     | alert   | timeo      | timeg      | typeo | typeg | transfer |
+-----+--------+----------+--------------+------------+----------+---------+------------+------------+-------+-------+----------+
| 140 |     26 |       24 |            5 |          6 | win test | request | 1242915564 | 1242915564 |     0 |     0 |          |
+-----+--------+----------+--------------+------------+----------+---------+------------+------------+-------+-------+----------+
1 row in set (0.00 sec)
Notice that the operator ID changed when the new operator got the request.  I know previously we stated that it would be nice if the higher operator still had access to that chat, but I am more concerned about the 2 operators in a chat.

So, since I am already aware of a bug where the monitor widow doesn't update operly (the chat request stays shown on operator 1's window when operator 2 gets it or the chat ends).  And I noticed that when a new chat request comes in, the first chat is removed and replaced by the second chat, I think that is the place to look.  Get the refresh fixed so it isn't being shown once it has moved past the operator.

So, if I can just figure out what is different between a new chat request versuse an update, I think I am there.  Of course, I really don't know where to look yet and dont' really know how to debug a php script <sigh>

- brian
Logged
BrianP
Not too much to say...
*
Offline Offline

Posts: 30


« Reply #12 on: May 21, 2009, 03:46:11 PM »

Okay, so what you are basically doing is combining server side code (PHP) with client side code (javascript) and the browser (and apache) can't figure out what you want it to do.

BTW, I am an idiot, I should have realized this myself.

- brian
Logged
SpenserJ
Moderator
HCL Regular
*****
Offline Offline

Posts: 179

Some helpful guy


WWW
« Reply #13 on: May 21, 2009, 07:50:45 PM »

BTW, I am an idiot, I should have realized this myself.

Its a mistake we all make once or twice. Not an hour after I had replied to you did I have a friend with the exact same issue Tongue

Nope, this doesn't work.  The first operator is getting the message the Someone is chatting already message.  The client still starts the chat, but I have no operator at the other end.  I think the problem is at this point, the database/sessions has already been updated to indicate the chat has been started (I believe by class/monitor.php::chats() but I am not sure who calls that, or the first time the page refreshes it calls this code and hits the check, I can't tell.

Bummer, I thought we were there, I will keep looking, but.....

- brian

It could also be that my code was a bit wrong and it doesn't return null, but instead returns false or '' or something. But if it is already updating the db, we should definitely fix it at the root of the problem.

On a separate note, I still haven't heard back from anyone on an update on this, and I am tempted to start making my own if I don't see any progress being made, or the code being made public. Its bull that we have to fix all of these bugs while we wait yet another year for v3
Logged

I am NOT a developer for HelpCenterLive. I am just trying to help out anyone that has issues. If you have a problem, check the list of fixes and then create a new topic
BrianP
Not too much to say...
*
Offline Offline

Posts: 30


« Reply #14 on: May 21, 2009, 08:56:35 PM »

Well, I figured out how to get debug messages in the php code, so I am making some progress.....

It could also be that my code was a bit wrong and it doesn't return null, but instead returns false or '' or something. But if it is already updating the db, we should definitely fix it at the root of the problem.

Well, I have found the code to prevent updating the database.  Now, based on the fact that the sessions table gets updated and the operator ID changed when it is round robining, I am making the assumption that once your time is passed, you can't start a chat anymore (which is not that Spenser wanted as above, but...).  So, I put in this change in class/monitor.php
Code:
        function accept_chat($id, $chatid)
        {
            if ($id == 0) {
                $this->result = $GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `chatid`="'.$chatid.'" ORDER BY `id` DESC');
                $id = $this->result[0]['id'];
            }
// see if this is still available for this operator
if ($GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `alert`="received" AND `operatorid`="'.$GLOBALS['operator']->id().'"'))
{
            $this->new_time = time() + $GLOBALS['conf']['chat_timeout'];
            $GLOBALS['db']->query('UPDATE `sessions` SET `alert`="accept", `operatorid`="'.$GLOBALS['operator']->id().'", `timeo`="'.$this->new_time.'"
, `timeg`="'.$this->new_time.'" WHERE `id`="'.$id.'" AND `chatid`="'.$chatid.'"');
            $GLOBALS['db']->query('DELETE FROM `chat` WHERE `chatid`="'.$chatid.'"');
            $GLOBALS['stats']->accept($GLOBALS['operator']->id());
            // Autosave transcript
            $GLOBALS['transcript']->create($chatid);
}
        }

But, the chat window still opens for the operator even though they shouldn't have it.  This puts it into some weird states (depending on if another operator has started the chat or not).  I need to figure out how to either stop the window from opening (really hard) or at least have that new window get the $GLOBALS['lang']['chat_empty'] message.  Which I think I need to do in the live/chat/main.php, I just don't know how yet.

Then I need to do something in the monitor to make the chat request messages go away when the timeout has happened for that operator.  I know there is a way, because the message will go away when the chat is started, I just haven't found it yet.  But I am focusing on preventing the chat first.

- brian
Logged
Pages: [1] 2   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.8 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.186 seconds with 20 queries.

Google visited last this page March 16, 2014, 03:08:58 AM