Skip to content

use laravel echo server in react native client #15474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mohsen158 opened this issue Aug 12, 2017 · 2 comments
Closed

use laravel echo server in react native client #15474

mohsen158 opened this issue Aug 12, 2017 · 2 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. Resolution: Locked This issue was locked by the bot.

Comments

@mohsen158
Copy link

I want to use laravel echo server in react native app
but I think something is wrong that I don't know what is it
I get this error in my log

undefined is not an object (evaluating 'this.connector.channel')
channel
D:\react-native\taav\node_modules\laravel-echo\dist\echo.js:750:34
componentDidMount

it is my laravel

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

/**
 * Create a new event instance.
 *
 * @return void
 */

public $activity;
public function __construct( Activity $a)
{
    //

    $this->activity=$a;

}

/**
 * Get the channels the event should broadcast on.
 *
 * @return Channel|array
 */
public function broadcastOn()
{
    return ['channel'];
}

}

that I know my laravel server is correct because I can use correctly my socket in browser

and my react native code:

import React, {Component} from 'react';
 
 import Echo from "laravel-echo"
  import io from 'socket.io-client/dist/socket.io';

 export default class Activities extends Component {

constructor(props) {
    super(props)
    this.btnadd = this.btnadd.bind(this)
    this.SearchMethod = this.SearchMethod.bind(this)
    this.socket = io('http://'.concat(server).concat(':6001'), {json: false})

}
 componentDidMount() {


    var echo = window.Echo = new Echo({
        broadcaster: 'io',
        host: 'http://'.concat(server).concat(':6001')
    });

    window.Echo.channel('channel')
        .listen('updateStatus', (e) => {
            // this.additem()

        })
}
@chirag04
Copy link
Contributor

@facebook-github-bot stack-overflow

@facebook-github-bot
Copy link
Contributor

Hey @mohsen158, thanks for posting this! @chirag04 tells me this issue looks like a question that would be best asked on Stack Overflow. Stack Overflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only. See "What to Expect from Maintainers".

@facebook-github-bot facebook-github-bot added the Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. label Aug 13, 2017
@facebook-github-bot facebook-github-bot added the Ran Commands One of our bots successfully processed a command. label Aug 13, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Aug 13, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: For Stack Overflow A question for Stack Overflow. Applying this label will cause issue to be closed. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants