2016-11-27 56 views
0

Vue 2とlaravel-echo-serverを使用してLaravel Echo経由でブロードキャストイベントを受信しようとしていますが、動作しません。私はlaravel-echo-serverもdevモードに入れました。私はチャンネルに入ったのを見ることができますが、同時に放置していますか?それが問題なのであれば、それをやめてチャネルに留まるにはどうしたらいいですか? php artisan queue:work redisを実行しているので、ブロードキャストが起動されていることもわかります。イベントリクエストを送信するたびに、私はProcessed: Illuminate\Broadcasting\BroadcastEventを取得します。なぜこれは動作しませんか?私は文字通り怒っている。laravel echoブロードキャストを受信しない

window._ = require('lodash'); 

window.$ = window.jQuery = require('jquery'); 
require('bootstrap-sass'); 

window.Vue = require('vue'); 
require('vue-resource'); 

Vue.http.interceptors.push((request, next) => { 
    request.headers.set('X-CSRF-TOKEN', Laravel.csrfToken); 

    next(); 
}); 

import Echo from "laravel-echo" 

window.Echo = new Echo({ 
    broadcaster: 'socket.io', 
    host: 'http://test.dev:6001' 
}); 

私app.js:

は、ここに私のbootstrap.jsある

require('./bootstrap'); 

Vue.component('alert', require('./components/Alert.vue')); 

const app = new Vue({ 
    el: '#app', 
    data: { 
     users: [] 
    }, 
    created: function() { 
     window.Echo.channel('test-channel') 
      .listen('UserSignedUp', (e) => { 
       console.log(e); 
       console.log('test'); 
      }); 
    } 
}); 

マイイベント:

<?php 

namespace App\Events; 

use Illuminate\Broadcasting\Channel; 
use Illuminate\Queue\SerializesModels; 
use Illuminate\Broadcasting\PrivateChannel; 
use Illuminate\Broadcasting\PresenceChannel; 
use Illuminate\Broadcasting\InteractsWithSockets; 
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; 

class UserSignedUp implements ShouldBroadcast 
{ 
    use InteractsWithSockets, SerializesModels; 

    public $username; 

    public function __construct($username) 
    { 
     $this->username = $username; 
    } 

    public function broadcastOn() 
    { 
     return new Channel('test-channel'); 
    } 
} 

そして最後に、私のlaravelエコーサーバ。 json:

{ 
    "appKey": "somekey", 
    "authHost": "http://test.dev", 
    "authEndpoint": "/broadcasting/auth", 
    "database": "redis", 
    "databaseConfig": { 
     "redis": { 
      "port": "6379", 
      "host": "localhost" 
     }, 
     "sqlite": { 
      "databasePath": "/database/laravel-echo-server.sqlite" 
     } 
    }, 
    "devMode": true, 
    "host": "localhost", 
    "port": "6001", 
    "referrers": [], 
    "socketio": {}, 
    "sslCertPath": "", 
    "sslKeyPath": "" 
} 

私はどこにいてもエラーは発生しません。イベントが発生して処理されているようですが、エコーはイベントを受信して​​いないようです。前述したように、イベントが発生するたびに、私は、コンソール(laravel-エコーサーバ端末タブ)からこれを取得:

[TIME] - KEY joined channel: test-channel 
[TIME] - KEY left channel: test-channel 

答えて

4

うん、何らかの理由で私の私の.envファイル内BROADCAST_DRIVERlogに設定しました。賢い私(y)

関連する問題