Help Center Live Community
April 20, 2014, 01:39:57 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 16616 times)
SpenserJ
Moderator
HCL Regular
*****
Offline Offline

Posts: 179

Some helpful guy


WWW
« Reply #15 on: May 21, 2009, 09:33:19 PM »

Nice work Brian, you are making awesome progress! I hadn't even seen that function when I took a quick look in all of the files. Would you mind making a diff when you are done everything? Or if you send me the code I can make a diff/patch file with your changes!

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 #16 on: May 22, 2009, 08:56:21 PM »

So, here is where I am at.  I have made a change to prevent updating the database if an operator accepts a chat that has already expired their allotted time.  This change:
Code:
class/monitor.php
423a429,431
> // Only update the database if this is still available for this operator
> if ($GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `alert`="received" AND `operatorid`="'.$GLOBALS['operator']->id().'"'))
> {
429a438
> }

Now, the operator can still open the chat however, and either it will join an existing chat (but NOT clear the client chat window, which is very important), or it will wait for the chat to be joined and the comments will be added to that chat.

However, the monitor itself doesn't clear itself to indicate the chat has expired this operator and moved to the next.  I made this change:
Code:
class/monitor.php
391a392,396
> // See there are chats waiting for other operators and tell client to refresh monitor
> if ($GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `alert`="received" AND `operatorid`!="'.$GLOBALS['operator']->id().'"'))
> {
>     $this->response .= 'request-cancelled|';
> }
which clears the monitor screen of chats that are not valid.  This does cause extra page reloads of the monitor window.

There are still problems though.  The current implementation does not clear the monitor screen of the last operator in the round robin (bad), but if that operator tries to open it, they receive the not valid chat message.  It also leaves a small window (about 5 seconds) where two operators could get the same chat (the chat has moved to the next operator, but the first operator's screen hasn't refreshed.

So, I would still like to try to figure out how to get the chat window to be empty if the chat isn't valid, which is probably in live/chat/main.php but I haven't figured out if the operator ID is remotely available there.  Still looking.

If you are interested, I also made this change to add the timezone to the chat transcript in case your installation supports multiple timezones (mine does).  I also have the changes for the firefox 3.0.6 fix, which is posted elsewhere.

I will probably post a complete list when I am done with everything, but I thought I would at least provide the changes I have made so far.

- brian

Logged
SpenserJ
Moderator
HCL Regular
*****
Offline Offline

Posts: 179

Some helpful guy


WWW
« Reply #17 on: May 26, 2009, 08:34:57 PM »

Looking good Brian. I was away for the weekend, so I haven't been too into HCL for a little while, but I am gonna be getting back into it soon if all goes well. But you are definitely doing good on this! Gonna help a lot of people out

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 #18 on: May 26, 2009, 09:11:13 PM »

Well, ain't that a b!tch.  I solve the problem and I can't upload files to the forum....

Code:
The attachments upload directory is not writable. Your attachment or avatar cannot be saved.

And you can't remove an attachment from the post once you have it listed.  <sigh>  Let me recreate my entire post......

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

Posts: 30


« Reply #19 on: May 26, 2009, 09:26:17 PM »

Here are all the code changes I have made to my installation.  The only thing left is to have the chat request in the operator's monitor to be removed once the chat times out, but my boss doesn't care about that right now, to neither do I  Wink

Fix for preventing multiple operators from being on the same chat
Few of things to be aware of.  1) This will prevent an operator with a higher priority from accepting a chat after the system has moved it to the next operator.  2) I have only tested this with 2 operators and they do not have the same priority.  3) While there are chats waiting to be accepted, the monitor will do full refreshes, not just AJAX queries.

class/js/monitor.php: This change is needed to send the operator ID to the server when trying to open the new chat window.
Code:
52c52
< 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+'&operatorid='+'<?php echo($operatorid); ?>', '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':

class/monitor.php: This change prevents the database from being updated if the accept button is clicked and the chat has already moved on to the next operator.
Code:
391a392,396
> // See there are chats waiting for other operators and tell client to refresh monitor
> if ($GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `alert`="received" AND `operatorid`!="'.$GLOBALS['operator']->id().'"'))
> {
>     $this->response .= 'request-cancelled|';
> }
423a429,431
> // Only update the database if this is still available for this operator
> if ($GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `alert`="received" AND `operatorid`="'.$GLOBALS['operator']->id().'"'))
> {
429a438
> }

live/chat/main.php: This change prevents the pop-up chat window from connecting to a chat that has already moved on to the next operator.
Code:
53a54,64
> if ($GLOBALS['auth']->operator() && isset($_GET['admin']) && !isset($_GET['opchat']))
> {
>   // Check to make sure this is valid for this operator
>   if (! $GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `chatid`="'.addslashes($_GET['chatid']).'" AND `operatorid`="'.addslashes($_GET['operatorid']).'"'))
>   {
>     // And it isn't
>     $GLOBALS['template']->assign('onload', ' onload="Chat.empty();"');
>     $GLOBALS['template']->assign('text', $GLOBALS['lang']['chat_empty']);
>   }
>   else
>   {
58a70,71
>   } // if (! $GLOBALS['db']->query('SELECT * FROM `sessions` WHERE `alert`="received" AND `operatorid`="'.$GLOBALS['operator']->id().'"'))
> } // if ($GLOBALS['auth']->operator() && isset($_GET['admin']) && !isset($_GET['opchat']))

And that is it.  I have done a couple of other things:
Fix put timezone in transcript
class/transcript.php
Code:
33a34
>         var $timezone;
50a52
>                     $this->timezone = date('T');
59,60c61,62
<                         $this->text = '<span class="operator"><i>('.$this->timestamp.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.rawurldecode($this->text).'</span><br />';
<                         //$this->text = '<span class="operator"><i>('.$this->timestamp.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.char_to_html($this->text).'</span><br />';
---
>                         $this->text = '<span class="operator"><i>('.$this->timestamp.' '.$this->timezone.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.rawurldecode($this->text).'</span><br />';
>                         //$this->text = '<span class="operator"><i>('.$this->timestamp.' '.$this->timezone.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.char_to_html($this->text).'</span><br />';
62c64
<                         $this->text = '<span class="guest"><i>('.$this->timestamp.')</i> <b>'.$_SESSION['hcl_'.$chatid]['guest'].':</b> '.rawurldecode($message).'</span><br />';
---
>                         $this->text = '<span class="guest"><i>('.$this->timestamp.' '.$this->timezone.')</i> <b>'.$_SESSION['hcl_'.$chatid]['guest'].':</b> '.rawurldecode($message).'</span><br />';
77a80
>                     $this->timezone = date('T');
86c89
<                         $this->text = '<span class="operator"><i>('.$this->timestamp.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.char_to_html($this->text).'</span><br />';
---
>                         $this->text = '<span class="operator"><i>('.$this->timestamp.' '.$this->timezone.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.char_to_html($this->text).'</span><br />';
88c91
<                         $this->text = '<span class="guest"><i>('.$this->timestamp.')</i> <b>'.$_SESSION['hcl_'.$chatid]['guest'].':</b> '.rawurldecode($this->result2[$key]['message']).'</span><br />';
---
>                         $this->text = '<span class="guest"><i>('.$this->timestamp.' '.$this->timezone.')</i> <b>'.$_SESSION['hcl_'.$chatid]['guest'].':</b> '.rawurldecode($this->result2[$key]['message']).'</span><br />';
159a163
>                         $this->timezone = date('T');
168c172
<                             $this->text = '<span class="operator"><i>('.$this->timestamp.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.char_to_html($this->text).'</span><br />';
---
>                             $this->text = '<span class="operator"><i>('.$this->timestamp.' '.$this->timezone.')</i> <b>'.$_SESSION['hcl_'.$chatid]['operator'].':</b> '.char_to_html($this->text).'</span><br />';
170c174
<                             $this->text = '<span class="guest"><i>('.$this->timestamp.')</i> <b>'.$_SESSION['hcl_'.$chatid]['guest'].':</b> '.rawurldecode($this->result2[$key]['message']).'</span><br />';
---
>                             $this->text = '<span class="guest"><i>('.$this->timestamp.' '.$this->timezone.')</i> <b>'.$_SESSION['hcl_'.$chatid]['guest'].':</b> '.rawurldecode($this->result2[$key]['message']).'</span><br />';

Firefox 3.0.6 fix
class/js/aardvark.php
Code:
28c28,38
< function Aardvark(object) { this.object = object; this.xmlhttp = new XMLHttpRequest(); this.mac = navigator.platform.indexOf('Mac'); this.msie = navigator.userAgent.indexOf("MSIE"); this.image = new Image(); this.fallback = false; this.url = ''; this.variables = new Array(); this.vars = new Array(); this.connect_host = ''; this.install_host = ''; this.initiated = false; this.url_built = false; this.response = ''; this.gc = 'reset'; this.validateurl = function()
---
> function Aardvark(object) { this.object = object; this.xmlhttp = new XMLHttpRequest(); this.mac = navigator.platform.indexOf('Mac'); this.msie = navigator.userAgent.indexOf("MSIE"); this.image = new Image();
> /* Start Changed the following line to fix the Firefox 3.0.6 bug
> this.fallback = false;
> */
> if (navigator.appName == 'Microsoft Internet Explorer') {
>         this.fallback = false;
> } else {
>         this.fallback = true;
> }
> /* End Changed the following line to fix the Firefox 3.0.6 bug */
> this.url = ''; this.variables = new Array(); this.vars = new Array(); this.connect_host = ''; this.install_host = ''; this.initiated = false; this.url_built = false; this.response = ''; this.gc = 'reset'; this.validateurl = function()

Firefox 3.0.7 fix (I haven't tested this http://www.helpcenterlive.com/smf/sound_issues_with_firefox_307-t928.0.html)
templates/Bliss/monitor_content.tpl (or in your own template directory)
Code:
54c54
< <embed src="{$conf.url}/templates/{$conf.template}/sounds/{$sounds[i].file}.mp3" autostart="true" hidden="true">
---
> <embed src="{$conf.url}/templates/{$conf.template}/sounds/{$sounds[i].file}.mp3" autostart="true" hidden="true" type="audio/mpeg">
class/js/chat.php
Code:
155c155
< if ((x == 'o' && admin == 'false') || (x == 'g' && admin == 'true')) { parent.window.chat_display.document.body.innerHTML = parent.window.chat_display.document.body.innerHTML + this.chat_message; this.font_apply(); if (this.sounds_flag) { if (this.mac > -1) { parent.window.chat_type.document.getElementById('typing').innerHTML = '<embed src="<?php echo($GLOBALS['conf']['url']); ?>/templates/<?php echo($GLOBALS['conf']['template']); ?>/sounds/ding.mp3" id="message_sound" loop="false" autostart="true" hidden="true"></embed>';} else { parent.window.chat_type.document.getElementById('typing').innerHTML = '<object height="0" width="0" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"><param name="AutoStart" value="1" /><param name="FileName" value="<?php echo($GLOBALS['conf']['url']); ?>/templates/<?php echo($GLOBALS['conf']['template']); ?>/sounds/ding.mp3" /></object>';}
---
> if ((x == 'o' && admin == 'false') || (x == 'g' && admin == 'true')) { parent.window.chat_display.document.body.innerHTML = parent.window.chat_display.document.body.innerHTML + this.chat_message; this.font_apply(); if (this.sounds_flag) { if (this.mac > -1) { parent.window.chat_type.document.getElementById('typing').innerHTML = '<embed src="<?php echo($GLOBALS['conf']['url']); ?>/templates/<?php echo($GLOBALS['conf']['template']); ?>/sounds/ding.mp3" id="message_sound" loop="false" autostart="true" hidden="true" type="audio/mpeg"></embed>';} else { parent.window.chat_type.document.getElementById('typing').innerHTML = '<object height="0" width="0" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"><param name="AutoStart" value="1" /><param name="FileName" value="<?php echo($GLOBALS['conf']['url']); ?>/templates/<?php echo($GLOBALS['conf']['template']); ?>/sounds/ding.mp3" /></object>';}

- brian

(of, I have to b!tch a little)
You know, a little input from a developer would have helped a lot here.  If nothing else, just to understand the database layout.  I mean, I see the post on the front page of HCL
Code:
The 'community' certainly hasn't contributed much more than questions and overhead, and some outside assistance in handling that would really be appreciated.
I was (obviously) willing to make the fixes myself.  I was just looking for some info on how everything works.  <sigh>

« Last Edit: May 26, 2009, 09:28:14 PM by BrianP » Logged
SpenserJ
Moderator
HCL Regular
*****
Offline Offline

Posts: 179

Some helpful guy


WWW
« Reply #20 on: May 26, 2009, 11:00:16 PM »

You did good Brian. Sorry I didn't help more, but life has been a little hectic, and I ended up making my own live support script that syncs with MSN messenger since we needed something working in ALL browsers that was more convenient. But you did awesome on that and the code looks very good. What did you use to make the patch files?

And I agree, some developer input would have been nice. I knew a little bit more than you did, and that was about it. So getting someone who knows the code in here would have helped a ton!

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 #21 on: May 27, 2009, 02:10:39 PM »

But you did awesome on that and the code looks very good. What did you use to make the patch files?

I am a linux guy, so I just used diff between an original version of the file and my changed version.

In hindsight, it is also possible that the change to class/monitor.php would no longer be needed with the change to live/chat/main.php.  But I didn't test it without the change and I figured a single DB query wouldn't matter in the grand scheme of things.

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

Posts: 179

Some helpful guy


WWW
« Reply #22 on: May 27, 2009, 10:17:50 PM »

Okay, that is what I figured, but wanted to make sure

And no, I don't think a small query will slow much down.

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
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.18 seconds with 18 queries.

Google visited last this page April 09, 2014, 04:15:22 PM