Broadcasting / Broadcasters / PusherBroadcaster.php "," line ": 116

0

I'm doing a private chat with laravel pusher and vue 2.

The issue is that when I use the helper broadcast () it gives me a connection error and I have all the data correctly entered in the .env file. I also have the providers and with Echo laravel all configured. But even so, I'm getting this error that worries me. In pusher it says that the channel is busy but not. I do not know how to proceed. Greetings.

Controller:

 public function send(Request $request)
{
    $req=$request->all();
    //dd($request->all());
    $message = Message::create([
        'from'  => Auth::user()->id,
        'to'    => $req['contact_id'],
        'text'  => $req['text']
    ]);

    $aux=new NewMessage($message);


    broadcast($aux)->toOthers();


    return response()->json($message);
  //  return ['status' => 'Message Sent!'];
}

The file returns from where I send the event:

   mounted(){
        Echo.private('messages-${this.user.id}')
            .listen('NewMessage', (e) => {
                this.hanleIncoming(e.message);
            })
        axios.get('/contacts')
            .then((response) => {
                this.contacts = response.data;
            });
    },

And this would be the event:

class NewMessage implements ShouldBroadcast{
use Dispatchable, InteractsWithSockets, SerializesModels;

public $message;

/**
 * Create a new event instance.
 *
 * @return void
 */
public function __construct(Message $message)
{
    $this->message = $message;
}

/**
 * Get the channels the event should broadcast on.
 *
 * @return \Illuminate\Broadcasting\Channel|array
 */
public function broadcastOn()
{

    return new PrivateChannel('messages-' . $this->message->from);
    //return new PresenceChannel('messages.' . $this->message->to);
    //return new PrivateChannel('private-messages' . $this->message->to);
}

public function broadcastWith()
{
  //  dump(123456789);
    return ["message"   => $this->message];
   // return $this->message->toArray();
}}

I hope you can help me. Without more to say. Thanks.

    
asked by Andres 05.09.2018 в 23:25
source

0 answers