Skip to content

API Reference

channels_easy.generic.AsyncWebsocketConsumer (AsyncWebsocketConsumer)

emit(self, typ, data, to=None, close=None) async

Send message to given rooms

Parameters:

Name Type Description Default
typ str

message type

required
data Any

data which is json serializable

required
to Union[str, int, Iterable]

List of rooms or a single room

None
close Union[int, boolean]

Boolean or error code, If passed close socket after emitting message

None

Note: If to is not passed, emit message to self user

emit_error(self, data, close=None) async

Emit message with error type and data

Parameters:

Name Type Description Default
data Any

Any json serializable value

required
close Union[int, boolean]

Boolean or error code. If passed close socket after emitting error

None

join(self, room) async

Join room with passed name

Parameters:

Name Type Description Default
room Union[str, Iterable]

List of room or a single room

required

leave(self, room) async

Leave room with passed name

Parameters:

Name Type Description Default
room Union[str, Iterable]

List of room or a single room

required