Skip to content
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

How to disconnect inside a Chat client? #7

Open
rcpinheiro opened this issue Nov 18, 2019 · 1 comment
Open

How to disconnect inside a Chat client? #7

rcpinheiro opened this issue Nov 18, 2019 · 1 comment

Comments

@rcpinheiro
Copy link

I've altered the chatroom example to let the user exit the chatroom:

        $console = new TcpConnection(STDIN);
        $console->onMessage = function($console, $message) use ($mqtt){
            $message=trim($message);
            if ($message=="exit") {
                $mqtt->disconnect();
                die;
            } else {
                $mqtt->publish('testRoom', $message);
            }
        };

When the user enters "exit" I want the worker to stop but it reconnects always. I've tried using "$mqtt->doNotReconnect=true;" but it doesn't work.
Anyone knows how to do this?

@mouyong
Copy link
Contributor

mouyong commented Jul 18, 2022

Maybe you can use $mqtt->close() to close connection. @rcpinheiro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants