from typing import Any

from asgiref.typing import WebSocketConnectEvent, WebSocketDisconnectEvent, WebSocketReceiveEvent
from channels.consumer import AsyncConsumer, SyncConsumer, _ChannelScope
from channels.layers import BaseChannelLayer

class WebsocketConsumer(SyncConsumer):
    groups: list[str] | None
    scope: _ChannelScope
    channel_name: str
    channel_layer: BaseChannelLayer
    channel_receive: Any
    base_send: Any

    def __init__(self, *args: Any, **kwargs: Any) -> None: ...
    def websocket_connect(self, message: WebSocketConnectEvent) -> None: ...
    def connect(self) -> None: ...
    def accept(self, subprotocol: str | None = ..., headers: list[tuple[str, str]] | None = ...) -> None: ...
    def websocket_receive(self, message: WebSocketReceiveEvent) -> None: ...
    def receive(self, text_data: str | None = ..., bytes_data: bytes | None = ...) -> None: ...
    def send(  # type: ignore[override]
        self, text_data: str | None = ..., bytes_data: bytes | None = ..., close: bool = ...
    ) -> None: ...
    def close(self, code: int | bool | None = ..., reason: str | None = ...) -> None: ...
    def websocket_disconnect(self, message: WebSocketDisconnectEvent) -> None: ...
    def disconnect(self, code: int) -> None: ...

class JsonWebsocketConsumer(WebsocketConsumer):
    def receive(self, text_data: str | None = ..., bytes_data: bytes | None = ..., **kwargs: Any) -> None: ...
    def receive_json(self, content: Any, **kwargs: Any) -> None: ...
    def send_json(self, content: Any, close: bool = ...) -> None: ...
    @classmethod
    def decode_json(cls, text_data: str) -> Any: ...
    @classmethod
    def encode_json(cls, content: Any) -> str: ...

class AsyncWebsocketConsumer(AsyncConsumer):
    groups: list[str] | None
    scope: _ChannelScope
    channel_name: str
    channel_layer: BaseChannelLayer
    channel_receive: Any
    base_send: Any

    def __init__(self, *args: Any, **kwargs: Any) -> None: ...
    async def websocket_connect(self, message: WebSocketConnectEvent) -> None: ...
    async def connect(self) -> None: ...
    async def accept(self, subprotocol: str | None = ..., headers: list[tuple[str, str]] | None = ...) -> None: ...
    async def websocket_receive(self, message: WebSocketReceiveEvent) -> None: ...
    async def receive(self, text_data: str | None = ..., bytes_data: bytes | None = ...) -> None: ...
    async def send(  # type: ignore[override]
        self, text_data: str | None = ..., bytes_data: bytes | None = ..., close: bool = ...
    ) -> None: ...
    async def close(self, code: int | bool | None = ..., reason: str | None = ...) -> None: ...
    async def websocket_disconnect(self, message: WebSocketDisconnectEvent) -> None: ...
    async def disconnect(self, code: int) -> None: ...

class AsyncJsonWebsocketConsumer(AsyncWebsocketConsumer):
    async def receive(self, text_data: str | None = ..., bytes_data: bytes | None = ..., **kwargs: Any) -> None: ...
    async def receive_json(self, content: Any, **kwargs: Any) -> None: ...
    async def send_json(self, content: Any, close: bool = ...) -> None: ...
    @classmethod
    async def decode_json(cls, text_data: str) -> Any: ...
    @classmethod
    async def encode_json(cls, content: Any) -> str: ...
