Преглед изворни кода

增加Worker的自定义协议支持,可以使用namespace直接指定协议

LingFeng Chen пре 9 година
родитељ
комит
8a35dd5172
1 измењених фајлова са 15 додато и 8 уклоњено
  1. 15 8
      Worker.php

+ 15 - 8
Worker.php

@@ -1356,14 +1356,21 @@ class Worker
         list($scheme, $address) = explode(':', $this->_socketName, 2);
         // Check application layer protocol class.
         if (!isset(self::$_builtinTransports[$scheme])) {
-            $scheme         = ucfirst($scheme);
-            $this->protocol = '\\Protocols\\' . $scheme;
-            if (!class_exists($this->protocol)) {
-                $this->protocol = "\\Workerman\\Protocols\\$scheme";
-                if (!class_exists($this->protocol)) {
-                    throw new Exception("class \\Protocols\\$scheme not exist");
-                }
-            }
+			
+			if(class_exists($scheme){
+				$this->protocol = $scheme;
+			} else {
+				$scheme         = ucfirst($scheme);
+				$this->protocol = '\\Protocols\\' . $scheme;
+				if (!class_exists($this->protocol)) {
+					$this->protocol = "\\Workerman\\Protocols\\$scheme";
+					if (!class_exists($this->protocol)) {
+						throw new Exception("class \\Protocols\\$scheme not exist");
+					}
+				}
+			}
+			
+            
             $local_socket = $this->transport . ":" . $address;
         } else {
             $this->transport = self::$_builtinTransports[$scheme];