Skip to content

Consider supporting dynamic namespaces #1854

@davidbau

Description

@davidbau

Consider supporting dynamic namespaces. Dynamic namespaces are a key tool for environments where all the complex application logic is in the browser, and the server just wants to reflect. They allow modularity without special server help.

I've implemented dynamic namespaces here as a subclass of socket.io Server:
https://github.com/PencilCode/dynamic.io

That page explains the idea. Basically, it adds a new server.setupNamespace(pattern, callback) to handle "new namespace" callbacks (return false to reject the namespace). Dynamically created namespaces expire after all sockets disconnect.

This is also helpful for setting up subdomains. Constructing a server with { host: 'myhost.com' } adds qualification of namespaces are by-host. nsp.fullname() returns strings like "//myhost.com/mynsp" (except for config.host, which retains the default "/", to stay compatible with the base class). This dovetails well with dynamic namespaces for sites that use DNS subdomains for organizing projects.

Consider including this functionality in the socket.io Server base class itself so that this subclass is unnecessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions