Skip to content

Core\Topic

Sends values between WebSocket connections and event streams. A connection joins a topic by name with subscribe. Any script can send a value to everyone who joined with publish, and the value arrives at their next receive().

Members

3 members.

MemberSignature
subscribesubscribe(string $topic): void
publishpublish(string $topic, mixed $value): uint
unsubscribeunsubscribe(string $topic): void

Example apps

These complete apps use this class. You can download and run each one.

  • Chat: A chat app with rooms, WebSockets and SQLite. One Novis server sends the pages and runs every connection, with no separate WebSocket server and no library.
  • Poll: A live poll with SQLite and server-sent events. Every open page shows each new vote at once, with no extra server and no library.