Rocky_Mountain_Vending/.pnpm-store/v10/files/6f/2b09d6a7fad1b0e389936428a4f2a684cfb7a80a0a129135193c8b3ea5eeefc357e3d2d2b478a983ebe6e36a92585b6fcc1f1b50963a84650333b8b60ad69b
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

50 lines
1.2 KiB
Text

/**
* @license
* Copyright 2020 Google Inc.
* SPDX-License-Identifier: Apache-2.0
*/
import type {ConnectionTransport} from './ConnectionTransport.js';
/**
* @internal
*/
export class BrowserWebSocketTransport implements ConnectionTransport {
static create(url: string): Promise<BrowserWebSocketTransport> {
return new Promise((resolve, reject) => {
const ws = new WebSocket(url);
ws.addEventListener('open', () => {
return resolve(new BrowserWebSocketTransport(ws));
});
ws.addEventListener('error', reject);
});
}
#ws: WebSocket;
onmessage?: (message: string) => void;
onclose?: () => void;
constructor(ws: WebSocket) {
this.#ws = ws;
this.#ws.addEventListener('message', event => {
if (this.onmessage) {
this.onmessage.call(null, event.data);
}
});
this.#ws.addEventListener('close', () => {
if (this.onclose) {
this.onclose.call(null);
}
});
// Silently ignore all errors - we don't know what to do with them.
this.#ws.addEventListener('error', () => {});
}
send(message: string): void {
this.#ws.send(message);
}
close(): void {
this.#ws.close();
}
}