class ServerController extends Controller
{
public function actionStart($port = 27015)
{
$server = new ChatServer();
if ($port) {
$server->port = $port;
}
$server->on(WebSocketServer::EVENT_WEBSOCKET_OPEN, function ($e) use ($server) {
echo "Server started at port " . $server->port;
});
$server->start();
}
}
class ChatServer extends WebSocketServer
{
public function init()
{
parent::init();
$this->on(self::EVENT_CLIENT_CONNECTED, function (WSClientEvent $e) {
$e->client->name = null;
});
}
protected function getCommand(ConnectionInterface $from, $msg)
{
$request = json_decode($msg);
return !empty($request->action) ? $request->action : parent::getCommand($from, $msg);
}
public function commandMessage(ConnectionInterface $client, $msg)
{
$instruction = json_decode($msg);
if ($instruction->message) {
if ($instruction->message) {
foreach ($this->clients as $chatClient) {
$chatClient->send(json_encode([
'action' => 'amess',
'message' => $instruction->message,
]));
}
}
}
}
}
Permission denied, please try again.
Permission denied, please try again.
ogin@server: Permission denied (publickey,password).
ERROR: Job failed: exit code 1
но я хочу чтобы она подгружалась в автолоаде автоматом и я мог использовать её по всему yii.
В моём случае это: https://github.com/walkor/Workerman
Я хочу сделать чтобы она грузилась по всему Yii через use