/shiny:shiny-universal-hubsfrom shiny
Generate code using Shiny.UniversalHubs - SignalR style hubs between nearby devices over any transport (Bluetooth LE, HTTP/WebSocket with mDNS and tunnels, Apple MultipeerConnectivity, Google Nearby Connections, or your own), with a source generated client proxy, typed pushes, groups, streaming, per hub transports, serializers and BLE services, transport priority and runtime enable/disable, resume, file transfers, media channels (live audio/video packet pipes) and dynamic hubs
Ships in shiny. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
SignalR-style hubs between nearby devices, over any transport. A hub is written once and served over the transports it
picks; every client shares its groups and pushes whichever way it connected. Read reference/api-reference.md for the
full API.
Shiny.UniversalHubs + Shiny.UniversalHubs.BluetoothLE. Translate old code
with the upgrade table at the end.| Package | Adds |
|---|---|
Shiny.UniversalHubs | hubs, host, client, transport seams, protocols, source generator (net11.0) |
Shiny.UniversalHubs.BluetoothLE | UseBluetoothLE - GATT characteristics, L2CAP files and media; registers platform BLE stacks |
Shiny.UniversalHubs.Http | UseHttp - a WebSocket per hub connection on Shiny.Net.HttpServer, mDNS, tunnels |
Shiny.UniversalHubs.Multipeer | UseMultipeer - Apple only (iOS, Mac Catalyst, macOS) |
Shiny.UniversalHubs.Nearby | UseNearby - Android, iOS, macOS |
Projects that declare contracts or hubs get the generator from the Shiny.UniversalHubs package.
[UniversalHubContract]
public interface IGameHub
{
Task<bool> Move(int cell); // Task or Task<T>, optional trailing CancellationToken
IAsyncEnumerable<Score> Scores(CancellationToken ct); // streaming
event Action<GameState> StateChanged; // host -> client push (Action / Action<...>)
}
public class GameHub(IGameStore store) : UniversalHub<IGameHub> // new instance + DI scope per call
{
public async Task<bool> Move(int cell)
{
await this.Clients.All.StateChanged(await store.Apply(this.Context.ConnectionId, cell));
return true;
}
public async IAsyncEnumerable<Score> Scores([EnumeratorCancellation] CancellationToken ct) { yield break; }
public override Task OnConnectedAsync(HubConnection connection) => Task.CompletedTask;
public override Task OnDisconnectedAsync(HubConnection connection, HubDisconnect disconnect) => Task.CompletedTask;
}
this.Context (HubCallerContext: ConnectionId, Client, Items, ConnectionAborted, Abort()), this.Clients
(All, Others, Caller, Client(id), Group(name), ...), this.Groups, this.Connection.Context.Items - hub instances don't live between calls.IHubContext<GameHub> (Clients, Groups, ConnectedClients, Disconnect, Start, Stop,
ClientConnected/Disconnected, MediaChannelOpened).services.AddUniversalServer(server => server
.Configure(o => { o.LocalName = "Host"; o.EnableFileTransfers(dir); o.EnableMediaChannels(); })
.Multipeer("mygame-mc")
.Nearby("com.mycompany.mygame")
.AddHub<GameHub>("game", hub => hub
.MaxClients(6)
.ValidateClient(info => info.Name == null ? "Name required" : null)
.UseHttp("_mygame._tcp")
.UseMultipeer()
.UseNearby()
.UseBluetoothLE("180D", "6e400002-b5a3-f393-e0a9-e50e24dcca9e")));
await host.Start(); // IUniversalHubHost: every hub on its transports
await host.Stop<BleHostTransport>(); // one transport off
await host.StartHub<GameHub, HttpHostTransport>();
Rules:
AddUniversalServer once per app; every hub inside it. Hub names: 1-64 of letters, digits, ., _, -; unique.IsSupported = false.connection.Transport is BleHostTransport, connection.Peripheral(), connection.HttpContext(),
connection.MultipeerPeer(), connection.NearbyPeer().UseBluetoothLE(service, characteristic, advertise: true). Every advertised service (running or not) must fit one
31-byte advertisement - registration throws otherwise. One 128-bit UUID fits; two don't. Prefer 16/32-bit UUIDs
("180D", "ABCD1234"), a shared service, or advertise: false.scanFor: (another advertised service of the host) or uses another transport.server.BluetoothLE(o => ...): ClientSweepInterval, SecureFileTransfers, SecureMediaChannels, FileTransfer,
DynamicServiceUuid. On plain .NET / macOS AppKit register IBleManager / IBleHostingManager yourself.UseHttp(mdnsServiceType, allowTunnel); server.Http(o => BasePath / Advertise / ServiceType / ManageHttpServer / DynamicServiceTypes); server.HttpServer(http => ...) for the server itself (e.g. AddQuickTunnel()).{BasePath}/{hub name}; the peer-link session inside carries calls, pushes, resume, files and media.allowTunnel is 404. Authenticate with connection.HttpContext()?.User.HttpHubHost.FromUrl(uri).Implement IHubTransport (DisplayName, IsSupported, IsRunning, Start, Stop, optional HostRenamed) and add it
with hub.UseTransport<MyTransport>(settings) (read back via hub.GetSettings<T>()); DI constructs it. It talks to each
hub through IHubBinding.Endpoint (IHubEndpoint) with an IHubPeerChannel per client (implement Transport and
GetFeature so HubConnection can describe the client). Client side: IHubClientTransport (Discover returns
HubHostSightings with your HubEndpoint subclass; Connect calls HubClientContext.Connect(events => link) with an
IHubConnectionTransport), added with o.UseTransport(sp => new MyClientTransport(...)).
services.AddUniversalHubClient<IGameHub>("game", o => o
.UseHttp("_mygame._tcp")
.UseMultipeer("mygame-mc")
.UseNearby("com.mycompany.mygame")
.UseBluetoothLE("180D", "6e400002-b5a3-f393-e0a9-e50e24dcca9e")
.Priority<NearbyClientTransport, HttpClientTransport>()); // optional; default = Use… order
using var scan = client.DiscoverAll().Subscribe(host => { /* host.Transports, host.Endpoint<BleHubEndpoint>()?.Rssi */ });
await client.Connect(host, new HubConnectOptions("Allan").Prefer<BleClientTransport>());
await client.Hub.Move(4);
await client.Disable<BleClientTransport>(); // Enable / Solo / IsEnabled / EnabledChanged
Allow<T>() restricts, Only<T>() = just that one.client.Transport is the transport in use; Status, StatusChanged, Disconnected, Rename, UploadFile,
DownloadFile, OpenMediaChannel work on every transport.UseHttp(type, h => { h.ConnectTimeout; h.RediscoverTimeout; h.MessageHandlerFactory; h.MaxMessageSize; }).IHubSerializer (Name, Serialize<T>, Deserialize<T>); default JsonHubSerializer ("json", Shiny's AOT JSON - add
your JsonSerializerContext with Json.AddContext(...)). Per hub: hub.Serializer(x); per client: o.Serializer(x).
Names must match or the handshake refuses. Dynamic hubs are JSON.
UniversalServerOptions.ResumeWindow (30 s), missed pushes
replayed (ResumeBufferSize 128). Client status Reconnecting meanwhile; AutomaticReconnect on the client options.HubDisconnect(Reason, Message): ClientDisconnect, ClientTimeout, ServerDisconnect, ServerShutdown,
ConnectionFailed.o.EnableFileTransfers(dir, ft => ...) + o.AuthorizeFile (all transports); client UploadFile,
UploadStream, DownloadFile -> HubFileTransferResult, progress HubTransferProgress.o.EnableMediaChannels(maxPacketSize); client.OpenMediaChannel() -> IHubMediaChannel
(Send, Receive, Completion); host IHubContext.MediaChannelOpened.server.AllowDynamicHubs(o => o.MaxHubs = 6).Http(o => o.DynamicServiceTypes.Add("_mygame._tcp"));
var hub = dynamicHubs.Add(new DynamicHubDefinition("trivia").UseHttp("_mygame._tcp").UseBluetoothLE(characteristic), handler);
await hub.Start();
// clients without a contract
services.AddDynamicHubClients(o => o.UseHttp());
var client = dynamicClients.Create("trivia", o => o.UseHttp("_mygame._tcp"));
await client.Hub.Invoke("Answer", [json]);
| Id | Meaning |
|---|---|
| SUH001 | The hub doesn't implement a contract method |
| SUH002 | Unsupported hub method return type (use Task, Task, IAsyncEnumerable) |
| SUH003 | Hub methods can't be overloaded |
| SUH004 | Unsupported hub event (use Action / Action<...>) |
| SUH005 | The hub's contract isn't marked [UniversalHubContract] |
| SUH006 | Unsupported hub method signature |
| SUH007 | A contract declares a property or indexer (only methods and Action events) |
| SUH008 | Hub contracts can't be generic |
| SUH009 | A contract member name collides with the generated proxy (Hub, OnPush, ...) or is both a method and an event |
NSBluetoothAlwaysUsageDescription, NSLocalNetworkUsageDescription, NSBonjourServices with
each hub's mDNS type, _{mc}._tcp + _{mc}._udp for Multipeer, NearbyProtocol.BonjourServices(serviceId) for
Nearby; clients add NSAllowsLocalNetworking.INTERNET, ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE, CHANGE_WIFI_MULTICAST_STATE,
usesCleartextTraffic; Nearby adds its own and needs Google Play services.| Old | New |
|---|---|
Shiny.BluetoothLE.Hubs(.Host/.Client), Shiny.UniversalHubs.Host/.Client | Shiny.UniversalHubs + transport packages |
using Shiny.BluetoothLE.Hubs; | using Shiny.UniversalHubs; |
[BleHubClient], BleHub<T> | [UniversalHubContract], UniversalHub<T> |
AddBleHubServer, AddHub<T>(characteristic, mdnsType, o => ...) | AddUniversalServer(s => s.AddHub<T>("name", h => h.UseBluetoothLE(svc, chr).UseHttp(type))) |
AddBleHubClient<T>, AddUniversalHubClient<T>(characteristic, mdnsType, ...) | AddUniversalHubClient<T>("name", o => o.UseBluetoothLE(svc, chr).UseHttp(type)) |
IBleHubClient<T>, IBleHubConnection, IBleHubSerializer, BleHubException, BleHubRemoteException, IBleHubMediaChannel, BleHubClientStatus | IUniversalHubClient<T>, IHubConnection, IHubSerializer, HubException, HubRemoteException, IHubMediaChannel, HubClientStatus |
HubTransports flags, Prefer/Allowed | transport types: Start<T>(), Prefer<T>(), Allow<T>(), Only<T>() |
HubHostInfo.Ble/.Http/.Multipeer/.Nearby, .Rssi, HubHostInfo.FromUrl | Endpoint<BleHubEndpoint>(), IsSeenOver<T>(), HttpHubHost.FromUrl |
connection.Ble/.Http/.Multipeer/.Nearby | connection.Peripheral(), .HttpContext(), .MultipeerPeer(), .NearbyPeer() |
| one BLE service UUID for all hubs | per-hub service, advertise:, 16/32-bit UUIDs |
DynamicHubDefinition(name, characteristic, serviceType) | new DynamicHubDefinition(name).UseHttp(type).UseBluetoothLE(chr) |
SBH0xx | SUH0xx |
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub shinyorg/skills --plugin shiny57 skills in this plugin
/localizegenGenerate strongly-typed localization classes from .resx resource files using Shiny.Extensions.Localization.Generator for .NET applications/shiny-accessorysetupGenerate code using Shiny.BluetoothLE.AccessorySetup - the system accessory pairing sheet for BLE devices (AccessorySetupKit on iOS 18+, CompanionDeviceManager on Android) with no MFi, no location prompt and no general Bluetooth prompt on iOS; picked accessories open as Shiny.BluetoothLE peripherals, and Android adds background presence (device appeared / disappeared) events/shiny-actorsGenerate code using Shiny.Actors — Orleans-style virtual actors without the ceremony, AOT/trim-clean, running anywhere .NET runs including .NET MAUI and Blazor WebAssembly. Covers actor interfaces and source-generated proxies, the ShinyActorBuilder (AddShinyActors), persistent state with ETags, named states and auto-save, event-sourced JournaledActor with snapshots, state and event migrations, typed streams (durable, implicit consumers), timers and persistent reminders (background jobs via Shiny.Jobs, on-time OS notifications via Shiny.Notifications), concurrency control ([Reentrant], [AlwaysInterleave], [ReadOnly], [StatelessWorker]), call filters and request context, OpenTelemetry traces and metrics, remoting over HTTP (Shiny.Net.HttpServer server, RemoteActorSystem client), mDNS discovery of actor servers, Shiny.DocumentDb storage (SQLite, PostgreSQL, IndexedDB...), and the ActorTestHost testing kit.Other plugins' skills for the same job