private function handleMSG($line)
{
$parts = explode(' ', $line);
$subject = null;
$length = trim($parts[3]);
$sid = $parts[2];
if (count($parts) == 5) {
$length = trim($parts[4]);
$subject = $parts[3];
} elseif (count($parts) == 4) {
$length = trim($parts[3]);
$subject = $parts[1];
}
$payload = $this->receive($length);
$msg = new Message($subject, $payload, $sid, $this);
if (!isset($this->subscriptions[$sid])) {
throw new Exception('subscription not found');
}
$func = $this->subscriptions[$sid];
if (is_callable($func)) {
$func($msg);
} else {
throw new Exception('not callable');
}
return;
}