"""Django Channels URL routing for WebSocket consumers.

Add to your project's ASGI routing::

    # asgi.py or routing.py
    from channels.routing import ProtocolTypeRouter, URLRouter
    from channels.auth import AuthMiddlewareStack
    from django_devicehub.realtime.routing import websocket_urlpatterns

    application = ProtocolTypeRouter({
        "http": get_asgi_application(),
        "websocket": AuthMiddlewareStack(
            URLRouter(websocket_urlpatterns)
        ),
    })

WebSocket URL patterns:
    ws://host/ws/iot/{device_type}/               — all devices of a type
    ws://host/ws/iot/{device_type}/{device_id}/    — specific device
"""

from django.urls import path

from .consumers import DeviceConsumer

websocket_urlpatterns = [
    path(
        "ws/iot/<str:device_type>/<str:device_id>/",
        DeviceConsumer.as_asgi(),
        name="ws-iot-device",
    ),
    path(
        "ws/iot/<str:device_type>/",
        DeviceConsumer.as_asgi(),
        name="ws-iot-type",
    ),
]
