forked from Devristo/phpws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,810 additions
and
1,777 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
<?php | ||
require_once("websocket.client.php"); | ||
|
||
class WebSocketAdminClient extends WebSocket{ | ||
protected $adminKey = null; | ||
|
||
public function __construct($url, $adminKey){ | ||
parent::__construct($url); | ||
|
||
$this->adminKey = $adminKey; | ||
|
||
$this->addHeader("Admin-Key", $adminKey); | ||
} | ||
|
||
|
||
public function sendMessage(WebSocketAdminMessage $msg){ | ||
$wsmsg = WebSocketMessage::create(json_encode($msg)); | ||
|
||
parent::sendMessage($wsmsg); | ||
} | ||
} | ||
|
||
/** | ||
* Helper class to send Admin Messages to the WebSocketServer | ||
* | ||
* Makes the server execute onAdminXXXX() events | ||
* | ||
* @author Chris | ||
* | ||
*/ | ||
class WebSocketAdminMessage extends stdClass{ | ||
public $task = null; | ||
|
||
private function __construct(){ | ||
|
||
} | ||
|
||
/** | ||
* Create a message that will be send to the instance of the WebSocketServer | ||
* | ||
* @param string $task | ||
* @return WebSocketAdminMessage | ||
*/ | ||
public static function create($task){ | ||
$o = new self(); | ||
$o->task = $task; | ||
|
||
return $o; | ||
} | ||
<?php | ||
require_once("websocket.client.php"); | ||
|
||
class WebSocketAdminClient extends WebSocket{ | ||
protected $adminKey = null; | ||
|
||
public function __construct($url, $adminKey){ | ||
parent::__construct($url); | ||
|
||
$this->adminKey = $adminKey; | ||
|
||
$this->addHeader("Admin-Key", $adminKey); | ||
} | ||
|
||
|
||
public function sendMessage(WebSocketAdminMessage $msg){ | ||
$wsmsg = WebSocketMessage::create(json_encode($msg)); | ||
|
||
parent::sendMessage($wsmsg); | ||
} | ||
} | ||
|
||
/** | ||
* Helper class to send Admin Messages to the WebSocketServer | ||
* | ||
* Makes the server execute onAdminXXXX() events | ||
* | ||
* @author Chris | ||
* | ||
*/ | ||
class WebSocketAdminMessage extends stdClass{ | ||
public $task = null; | ||
|
||
private function __construct(){ | ||
|
||
} | ||
|
||
/** | ||
* Create a message that will be send to the instance of the WebSocketServer | ||
* | ||
* @param string $task | ||
* @return WebSocketAdminMessage | ||
*/ | ||
public static function create($task){ | ||
$o = new self(); | ||
$o->task = $task; | ||
|
||
return $o; | ||
} | ||
} |
Oops, something went wrong.