我的Laravel应用程序中有一个事件,对于特定的记录,它超出了Pusher允许的最大限制(10240字节)。 Laravel是否会序列化事件类上的每个公共属性? 如果是这样,我怀疑序列化模型不应该超过10kb的限制,但无论如何都失败了。 有没有方法可以减少数据内容的大小?
class PostChanged implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $post;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(Post $post)
{
$this->post = $post;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new Channel('post-channel.'.$this->post->id);
}
public function broadcastWith()
{
$extra = [
'data' => $this->post->data,
];
return array_merge($this->post->toArray(), $extra);
}
}
输出:
The data content of this event exceeds the allowed maximum (10240 bytes).
See http://pusher.com/docs/server_api_guide/server_publishing_events for more info
$post
的内容是什么?另外,为什么要两次添加$post->data
?它已经包含在$post
变量中了。 - Jerodev$post
对象是否需要序列化的。 - sarotnem