(
type: K,
payload: z.input<GetSocketMessageSchema<TEmitCatalog, K>>
)
| 261 | } |
| 262 | |
| 263 | async send<K extends GetSocketMessagesWithoutCallback<TEmitCatalog>>( |
| 264 | type: K, |
| 265 | payload: z.input<GetSocketMessageSchema<TEmitCatalog, K>> |
| 266 | ): Promise<void> { |
| 267 | const schema = this.opts.emitSchema[type]["message"]; |
| 268 | |
| 269 | if (!schema) { |
| 270 | throw new Error(`Unknown message type: ${type as string}`); |
| 271 | } |
| 272 | |
| 273 | const parsedPayload = schema.safeParse(payload); |
| 274 | |
| 275 | if (!parsedPayload.success) { |
| 276 | throw new ZodSchemaParsedError(parsedPayload.error, payload); |
| 277 | } |
| 278 | |
| 279 | await this.#sendPacket({ |
| 280 | type: "EVENT", |
| 281 | message: { |
| 282 | type, |
| 283 | payload, |
| 284 | version: "v1", |
| 285 | }, |
| 286 | }); |
| 287 | } |
| 288 | |
| 289 | public async sendWithAck<K extends GetSocketMessagesWithCallback<TEmitCatalog>>( |
| 290 | type: K, |
nothing calls this directly
no test coverage detected