Petr Schukin
Petr Schukin

Reputation: 227

How to close connection by channel name (kick user)

At some point of tine a want to close connection by channel name or kick an user? I can't use self.close as I'm not on that user at that point when I want to kick him. P.S. group_discard does not close a connection.

Upvotes: 0

Views: 284

Answers (1)

Ken4scholars
Ken4scholars

Reputation: 6296

You can send an event to websocket.diconnect just like the other consumer methods:


self.channel_layer.send(
    <channel_name>,
    {
        'type': 'websocket.disconnect',
        'code': <code>,
    }
)

Upvotes: 2

Related Questions