olofd / react-native-signalr

Use SignalR with React Native
150 stars 61 forks source link

Group cannot receive message #40

Open joyceljy opened 7 years ago

joyceljy commented 7 years ago

Hi, Im using Azure as server.

And my environment is as follows: Client 1: Web browser with Signalr JS installed Client 2: React-native app

Server: Asp.net C# Server with Signalr

When a client invoke a message , people in the group will receive messages. My web browser(Client1) received message successfully but my react-native app (Client2) didn't.

` componentDidMount() {

    const connection = signalr.hubConnection('http://signalrpj.azurewebsites.net');
    connection.logging = true;

    const proxy = connection.createHubProxy('chatHub');

    proxy.on('addMessage', (message1) => {
        console.log('message-from-server Group', message1);
        if (message1 == 'openMindwavePage') {
            proxy.invoke('send', this.props.login_account, 'haveOpened');
            this.props.MindWave();
            connection.stop();
        }
    });

    connection.start().done(() => {
        proxy.invoke('group', 'this.props.login_account');
        console.log('Now connected, connection ID=' + connection.id);
    }).fail(() => {
        console.log('Failed');
    });

}`

Please help ,Thanks Joyce

olofd commented 7 years ago

Don't know what you are doing wrong here. Did you get it working?

jp928 commented 7 years ago

@joyceljy Didn't see you have join group function.

daominhsangvn commented 7 years ago

@olofd I got the same issue, From the C# backend, I'm using method Clients.Group(roomName).addMessage(...); to send message to a group. From the React-Native, i invoke a method to join a group and listen callback addMessage. The callback addMessage never fired even i triggered from the api while the browser is working.

If i run the app from the react-native command $ react-native run-ios, it's working perfectly But when i try to run from xCode (Both Debug and Release), it's not working.

EDIT: I found out when i turn the remote debug on, it will work. Otherwise, it wont

daominhsangvn commented 6 years ago

I managed to fixed this issue, please see my package https://www.npmjs.com/package/%40nois%2Freact-native-signalr Check example.js file in github for example code

sepidar902 commented 5 years ago

Hi, Im using Azure as server.

And my environment is as follows: Client 1: Web browser with Signalr JS installed Client 2: React-native app

Server: Asp.net C# Server with Signalr

When a client invoke a message , people in the group will receive messages. My web browser(Client1) received message successfully but my react-native app (Client2) didn't.

` componentDidMount() {

    const connection = signalr.hubConnection('http://signalrpj.azurewebsites.net');
    connection.logging = true;

    const proxy = connection.createHubProxy('chatHub');

    proxy.on('addMessage', (message1) => {
        console.log('message-from-server Group', message1);
        if (message1 == 'openMindwavePage') {
            proxy.invoke('send', this.props.login_account, 'haveOpened');
            this.props.MindWave();
            connection.stop();
        }
    });

    connection.start().done(() => {
        proxy.invoke('group', 'this.props.login_account');
        console.log('Now connected, connection ID=' + connection.id);
    }).fail(() => {
        console.log('Failed');
    });

}`

Please help ,Thanks Joyce Duplicate of #https://github.com/olofd/react-native-signalr/issues/52#issuecomment-552065862