Skip to content

Commit

Permalink
修正websocket下request对象
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwuxin committed Dec 9, 2020
1 parent 633e366 commit 044caf6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
},
"config": {
"preferred-install": "dist",
"sort-packages": true
"sort-packages": true,
"platform-check": false,
"platform": {
"ext-swoole": "4.4.8",
"ext-fileinfo": "1.0.4"
}
}
}
12 changes: 9 additions & 3 deletions src/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@

class Table
{
public const TYPE_INT = 1;

public const TYPE_STRING = 3;

public const TYPE_FLOAT = 2;

/**
* Registered swoole tables.
*
Expand All @@ -25,7 +31,7 @@ class Table
/**
* Add a swoole table to existing tables.
*
* @param string $name
* @param string $name
* @param SwooleTable $table
*
* @return Table
Expand Down Expand Up @@ -62,11 +68,11 @@ public function getAll()
/**
* Dynamically access table.
*
* @param string $key
* @param string $key
*
* @return SwooleTable
*/
public function __get($key)
public function __get(string $key)
{
return $this->get($key);
}
Expand Down
2 changes: 1 addition & 1 deletion src/concerns/InteractsWithSwooleTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Trait InteractsWithSwooleTable
*
* @property Container $container
* @property App $app
* @property App $app
*/
trait InteractsWithSwooleTable
{
Expand Down
1 change: 1 addition & 0 deletions src/concerns/InteractsWithWebsocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function onOpen($server, $req)

$this->runInSandbox(function (Event $event, HandlerInterface $handler, App $app) use ($req) {
$request = $this->prepareRequest($req);
$app->instance('request', $request);
$request = $this->setRequestThroughMiddleware($app, $request);

if (!$handler->onOpen($req->fd, $request)) {
Expand Down

0 comments on commit 044caf6

Please sign in to comment.