作者 lyh

gx

... ... @@ -3,34 +3,23 @@
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class WebSocketMessageSent
class WebSocketMessageSent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
use Dispatchable, SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
public $message;
public function __construct($message)
{
//
$this->message = $message;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('channel-name');
return new Channel('websocket-channel');
}
}
... ...
... ... @@ -10,6 +10,7 @@
namespace App\Http\Controllers\Bside;
use App\Enums\Common\Code;
use App\Events\WebSocketMessageSent;
use App\Helper\Common;
use App\Helper\Translate;
use App\Helper\Wechat;
... ... @@ -18,6 +19,7 @@ use App\Models\Service\Service;
use App\Models\Sms\SmsLog;
use App\Models\User\User as UserModel;
use App\Utils\EncryptUtils;
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\SendMessage;
use \Illuminate\Support\Facades\Cache;
use Mrgoon\AliSms\AliSms;
... ... @@ -144,6 +146,7 @@ class LoginController extends BaseController
$message = file_get_contents("php://input");
$message = simplexml_load_string($message, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOERROR);
@file_put_contents(storage_path('logs/lyh_error.log'), $message . PHP_EOL, FILE_APPEND);
event(new WebSocketMessageSent('New message from server'));
$this->response('success');
}
... ...