-
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.
add incoming tcp request for auth user to laravel server
- Loading branch information
Showing
13 changed files
with
305 additions
and
49 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BeyondCode\LaravelWebSockets\Console; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
/** | ||
* Class Tcp | ||
* | ||
* @package Src\Jobs | ||
*/ | ||
class Tcp implements ShouldQueue | ||
{ | ||
use Dispatchable; | ||
use InteractsWithQueue; | ||
use Queueable; | ||
use SerializesModels; | ||
|
||
/** | ||
* Tcp constructor. | ||
* | ||
* @param object $user | ||
* @param object $data | ||
* @param string $class | ||
* @param array $routes | ||
* @param array $routeData | ||
*/ | ||
public function __construct( | ||
protected object $user, | ||
protected object $data, | ||
protected string $class, | ||
protected array $routes, | ||
protected array $routeData | ||
) | ||
{ | ||
} | ||
|
||
/** | ||
* Execute the job. | ||
* | ||
* @return void | ||
*/ | ||
public function handle(): void | ||
{ | ||
$broadcast = resolve($this->class); | ||
$method = array_values($this->routes[$this->routeData['url']])[0]; | ||
|
||
if (!method_exists($broadcast, $method)) { | ||
return; | ||
} | ||
|
||
$request = (new Request())->replace(['user' => $this->user, 'data' => (array) $this->data]); | ||
$broadcast->{$method}($request); | ||
} | ||
} |
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BeyondCode\LaravelWebSockets\WebSockets\Messages; | ||
|
||
use BeyondCode\LaravelWebSockets\Console\Tcp; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* Class MessageProvider | ||
* | ||
* @package Service\Socket\Messages | ||
*/ | ||
class MessageProvider | ||
{ | ||
/** | ||
* MessageProvider constructor. | ||
* | ||
* @param string $routeFile | ||
* @param array $routeData | ||
* @param Model $user | ||
* @param object $data | ||
*/ | ||
public function __construct( | ||
protected string $routeFile, | ||
protected array $routeData, | ||
protected Model $user, | ||
protected object $data | ||
) { | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function routeProvider(): void | ||
{ | ||
$routes = require base_path("routes/socket/$this->routeFile.php"); | ||
$class = array_keys($routes[$this->routeData['url']])[0]; | ||
|
||
if (!class_exists($class)) { | ||
return; | ||
} | ||
|
||
Tcp::dispatch( | ||
$this->user, | ||
$this->data, | ||
$class, | ||
$routes, | ||
$this->routeData | ||
)->onQueue(config('websockets.channels.queue_handler')); | ||
} | ||
} |
Oops, something went wrong.