From 9fdf072400f6b2540206588762108cfc58198f96 Mon Sep 17 00:00:00 2001 From: Alex Sosnovskiy Date: Thu, 20 Mar 2025 11:40:13 +0300 Subject: [PATCH] WebSocket: add protocols option --- src/treaty2/index.ts | 2 +- src/treaty2/ws.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/treaty2/index.ts b/src/treaty2/index.ts index fb4a599..6d542bb 100644 --- a/src/treaty2/index.ts +++ b/src/treaty2/index.ts @@ -223,7 +223,7 @@ const createProxy = ( path + q - return new EdenWS(url) + return new EdenWS(url, headers['Sec-WebSocket-Protocol']) } return (async () => { diff --git a/src/treaty2/ws.ts b/src/treaty2/ws.ts index 75da87a..b2bbbea 100644 --- a/src/treaty2/ws.ts +++ b/src/treaty2/ws.ts @@ -5,8 +5,8 @@ import { parseMessageEvent } from '../utils/parsingUtils' export class EdenWS = {}> { ws: WebSocket - constructor(public url: string) { - this.ws = new WebSocket(url) + constructor(public url: string, protocols?: string | string[]) { + this.ws = new WebSocket(url, protocols) } send(data: Schema['body'] | Schema['body'][]) {