happyDemon / vue-echo

Vue integration for the Laravel Echo library.
228 stars 24 forks source link

Presence and Private channel not working #7

Closed IgorDePaula closed 7 years ago

IgorDePaula commented 7 years ago

I tried a presence channel and nothing hapened

IgorDePaula commented 7 years ago

laravel echo server emit presence channel and private channel with '-' and not ':'

happyDemon commented 7 years ago

could you provide code samples?

The example in the readme is directed at auto-channel registration. behind the scenes

channel: 'private:team.1',

would be converted to:

this.channel = this.$echo.private('team.1');

same goes for presence.

Laravel Echo takes over from there and should prefix the channel names

IgorDePaula commented 7 years ago

The laravel echo server emit

[11:41:29] - UmmiNQ7kPnvRpWTlAAAj authenticated for: presence-testchannel
[11:41:29] - UmmiNQ7kPnvRpWTlAAAj joined channel: presence-testchannel

and vue echo wait por "presence:" and laravel echo emit "presence-"

happyDemon commented 7 years ago

without out any code samples(not socket server logs) I can't help you any further, does this mean that private and public do work on your end?

IgorDePaula commented 7 years ago

I change the charactere in your code and works, Thank you.

happyDemon commented 7 years ago

@IgorDePaula For a reference could you show me what code gave an error and which one you used that worked? so I can take it in or reference it in the future

IgorDePaula commented 7 years ago
<template>
  <div class="hello">
  </div>
</template>

<script>
  export default {
    name: 'hello2',
    data () {
      return {
        msg: 'Welcome to Your Vue.js App'
      }
    },
    channel:'presence:testchannel',
    echo: {
      'CategoriaEvent': payload => {
        console.log(payload);
      }
    },
    mounted() {
        const  myHeaders = new Headers();
myHeaders.append('Authorization', 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjcsImlzcyI6Imh0dHA6XC9cL2xvY2FsaG9zdDo4MDAwXC90b2tlbiIsImlhdCI6MTQ5MDI3NzE1NywiZXhwIjoxNDkwMjgwNzU3LCJuYmYiOjE0OTAyNzcxNTcsImp0aSI6ImUwNGI2M2Y1MTI5NTE2N2M2MTI1OTFlNTk3ZDdjMjFlIn0.hnpvq5YCWVJ0WuvhcTFfT7Bp22YE1CSB72ISaTISIpU')
      const myInit = { method: 'GET',
        headers: myHeaders,
        mode: 'cors',
        cache: 'default' };
      fetch('http://localhost:8000/cat', myInit)
        .then(function(response) {
         console.log(response);
          fetch('http://localhost:8000/', myInit)
            .then(function(response) {
              console.log(response);
            })
        })
      console.log('hello2 is present');

    }
  }
</script>
IgorDePaula commented 7 years ago

But is like I said: you need change ':' by '-'. The code above not work, but followed your docs.