# Sgcwebsockets Dotnet Protocols

> sgcWebSockets .NET Subprotocols

- Skill: `esegece-com/sgcwebsockets-dotnet-protocols` (Agent Skill, multi-file: 150 files)
- Install (CLI): `npx skillmds@latest add esegece-com/sgcwebsockets-dotnet-protocols`
- Raw SKILL.md: https://api.skillmd.com/api/skills/esegece-com/sgcwebsockets-dotnet-protocols/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: esegece-com (https://skillmd.com/u/esegece-com)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/esegece-com/sgcwebsockets-dotnet-protocols

---


# sgcWebSockets .NET Subprotocols

The subprotocols that ship with the library, each a matching client and server
pair. Unlike the message-broker skill, there is no external broker here: the
server component is the broker, and both ends come from this assembly.

Read `sgcwebsockets-dotnet` first. Every component here attaches to a transport,
clients through `Client` and servers through `Server`, and the transport is what
listens or connects.

## When to use this skill

- Publish and subscribe over channels between your own client and server
- Stream a file from one end to the other
- Track who is on a channel, and let members invite each other
- Encrypt messages end to end so the server cannot read them
- Talk WAMP v1 or consume a Lightstreamer feed

## Components in this skill

| Job | Client | Server |
| --- | --- | --- |
| Publish/subscribe, RPC, transactions | `TsgcWSPClient_sgc` | `TsgcWSPServer_sgc` |
| Message broker | | `TsgcWSPServer_Broker` |
| File transfer | `TsgcWSPClient_Files` | `TsgcWSPServer_Files` |
| Presence on a channel | `TsgcWSPClient_Presence` | `TsgcWSPServer_Presence` |
| End-to-end encryption | `TsgcWSPClient_E2EE` | `TsgcWSPServer_E2EE` |
| WAMP v1 | `TsgcWSPClient_WAMP` | |
| Lightstreamer | `TsgcWSPClient_Lightstreamer` | |

Note the casing: the .NET class is `TsgcWSPServer_Broker` with a capital B,
while the Delphi component is `TsgcWSPServer_broker`. C# is case sensitive, so
the .NET spelling is the one that compiles. `concepts/coverage.md` in the
`sgcwebsockets-dotnet` skill records the divergence.

## Before you start, ask the developer

Use a structured question tool if your host has one, for example Claude Code's
`AskUserQuestion`. Otherwise ask in chat:

1. **Do both ends belong to you?** These protocols are sgc-specific. A browser
   or a third-party client will not speak them without the matching JavaScript
   the product ships.
2. **Publish/subscribe or request/response?** `TsgcWSPClient_sgc` does both,
   through `Publish`/`Subscribe` and through `RPC`, and they have different
   failure modes.
3. **Does the server need to read the messages?** If yes, E2EE is the wrong
   tool: the point of it is that the server cannot.
4. **How large are the files?** File transfer over a WebSocket connection
   competes with everything else on that connection.

## Quickstart, publish and subscribe

```csharp
using esegece.sgcWebSockets;

var client = new TsgcWebSocketClient();
client.Host = "127.0.0.1";
client.Port = 5000;

var sgc = new TsgcWSPClient_sgc();
sgc.Client = client;

client.OnConnect += (TsgcWSConnection connection) =>
    sgc.Subscribe("prices");

client.Active = true;

// later, from anywhere
sgc.Publish("BTC 65000", "prices");
```

`Publish` sends to the channel's subscribers. `Broadcast` sends to everyone.
`RPC(idMethod, method, params)` calls the other end and `Notify(method, params)`
is the fire-and-forget form. `StartTransaction`, `Commit` and `RollBack` group
publishes on a channel.

The server side is the mirror: create `TsgcWSPServer_sgc`, set its `Server` to
a `TsgcWebSocketServer`, and start the server.

## End-to-end encryption, and what it costs

`TsgcWSPClient_E2EE` and `TsgcWSPServer_E2EE` encrypt so the server relays
ciphertext it cannot read. `GenerateIdentityKeyPair`, `CreateGroup`,
`JoinGroup`, `LeaveGroup` and `SendDirectMessage` are the surface.

The consequence is the one people miss: the server cannot filter, log, search or
moderate what it cannot read, and it cannot help a user who has lost a key. If
the application needs any of that, E2EE is the wrong layer and channel-level
authorisation on the server is the right one.

## Things that catch people out

- The protocol component is not the connection. Start the transport, not the
  protocol.
- One transport carries one protocol. Two protocol components on one client is
  the usual cause of a handshake failing.
- `Subscribe` on the file protocol takes a channel **and** a guid. It is not the
  same signature as the pub/sub `Subscribe`, and the type pages show both.
- A subscription lives on the connection. After a reconnect it has to be made
  again, which is why subscribing inside `OnConnect` rather than after
  `Active = true` is the pattern that survives a dropped network.
- Presence tells you who is on a channel, not who is authorised to be. The
  server decides that, in `OnBeforeSubscription`.
- `TsgcWSPServer_Broker` is a server-only component. There is no matching
  client: the pub/sub client talks to it.

## Routing

- **API detail**: `reference/api/<Component>.md` has the properties, events and methods, each with its C# signature.
- **Option / enum / delegate types**: property and event types link to `reference/types/<TypeName>.md`.
- **Examples**: `examples/<Component>.md` is a trimmed snippet from the shipped demo; `examples/index.md` maps every component to its demo.
- **Getting started**: `concepts/overview.md` covers the single `using`, the target frameworks and the naming.

## What is documented

Public instance properties, events and methods declared anywhere in the
library's own class chain. Members inherited from the .NET base classes are
left out, as are internals, so a page shows the surface a caller writes
against and nothing else.

If a component you need is not here, read `concepts/coverage.md` in the
`sgcwebsockets-dotnet` skill before assuming a different name for it.
This assembly carries fewer components than the Delphi library, and saying
so is more useful than guessing an API that does not exist.

