package cache
import (
"context"
"github.com/redis/go-redis/v9"
class CommentsChannel < ApplicationCable::Channel
def subscribed
post = find_post
if post
stream_for post
else
import {
WebSocketGateway,
WebSocketServer,
SubscribeMessage,
OnGatewayConnection,
OnGatewayDisconnect,
use axum::extract::ws::{Message, WebSocket, WebSocketUpgrade};
use axum::extract::State;
use axum::response::Response;
use axum::routing::get;
use axum::Router;
from dataclasses import dataclass, field
from datetime import datetime, timezone
from decimal import Decimal
def _now():
import asyncio
from collections import defaultdict
from fastapi import WebSocket
const { EventEmitter } = require('events');
const HIGH_WATER_MARK = 1 << 20; // 1 MiB of buffered bytes per client
class SseHub extends EventEmitter {
constructor() {
module DomainEvents
class Registry
def initialize
@subscribers = Hash.new { |h, k| h[k] = [] }
end
import React from 'react';
import { useToasts } from './useToasts';
export function Toaster() {
const { toasts, dismiss } = useToasts();
class PresenceRegistry
TTL = 30 # seconds a user counts as present without a heartbeat
def initialize(room_id, redis: REDIS)
@room_id = room_id
@redis = redis
@RestController
@RequestMapping("/api/notifications")
public class NotificationController {
private final SseEmitterRegistry registry;
private final NotificationService service;
package hub
type Hub struct {
subscribers map[*Subscriber]struct{}
broadcast chan []byte
register chan registration