-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release new realtime-js version #408
Changes from all commits
4616807
da5444b
514914a
3299d16
da49107
6e77a2d
d4b9e01
d03488c
cb01c57
308202a
a066325
3cd6789
2b76a10
5622571
31c9a1b
c445773
daf54a4
527d837
d9c9873
f679ae8
11e7739
399b220
00ba0e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,4 +55,4 @@ | |
"typedoc": "^0.22.16", | ||
"typescript": "^4.0.3" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,31 @@ | ||
import type { WebSocket as WSWebSocket } from 'ws' | ||
|
||
import { | ||
VSN, | ||
CHANNEL_EVENTS, | ||
TRANSPORTS, | ||
SOCKET_STATES, | ||
CONNECTION_STATE, | ||
DEFAULT_HEADERS, | ||
DEFAULT_TIMEOUT, | ||
SOCKET_STATES, | ||
TRANSPORTS, | ||
VSN, | ||
WS_CLOSE_NORMAL, | ||
DEFAULT_HEADERS, | ||
CONNECTION_STATE, | ||
} from './lib/constants' | ||
import Timer from './lib/timer' | ||
import Serializer from './lib/serializer' | ||
import Timer from './lib/timer' | ||
|
||
import { httpEndpointURL } from './lib/transformers' | ||
import RealtimeChannel from './RealtimeChannel' | ||
import type { RealtimeChannelOptions } from './RealtimeChannel' | ||
|
||
import type { WebSocket as WSWebSocket } from 'ws' | ||
|
||
type Fetch = typeof fetch | ||
|
||
export type Channel = { | ||
name: string | ||
inserted_at: string | ||
updated_at: string | ||
id: number | ||
} | ||
|
||
export type RealtimeClientOptions = { | ||
transport?: WebSocketLikeConstructor | ||
timeout?: number | ||
|
@@ -66,6 +75,7 @@ export default class RealtimeClient { | |
apiKey: string | null = null | ||
channels: RealtimeChannel[] = [] | ||
endPoint: string = '' | ||
httpEndpoint: string = '' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also this parameter too. Is there another PR that makes use of them? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be used for http broadcast (aka non ws connection broadcast for edge functions). It will also be useful for longpoll fallback |
||
headers?: { [key: string]: string } = DEFAULT_HEADERS | ||
params?: { [key: string]: string } = {} | ||
timeout: number = DEFAULT_TIMEOUT | ||
|
@@ -99,6 +109,7 @@ export default class RealtimeClient { | |
* Initializes the Socket. | ||
* | ||
* @param endPoint The string WebSocket endpoint, ie, "ws://example.com/socket", "wss://example.com", "/socket" (inherited host & protocol) | ||
* @param httpEndpoint The string HTTP endpoint, ie, "https://example.com", "/" (inherited host & protocol) | ||
* @param options.transport The Websocket Transport, for example WebSocket. | ||
* @param options.timeout The default timeout in milliseconds to trigger push timeouts. | ||
* @param options.params The optional params to pass when connecting. | ||
|
@@ -111,7 +122,7 @@ export default class RealtimeClient { | |
*/ | ||
constructor(endPoint: string, options?: RealtimeClientOptions) { | ||
this.endPoint = `${endPoint}/${TRANSPORTS.websocket}` | ||
|
||
this.httpEndpoint = httpEndpointURL(endPoint) | ||
if (options?.transport) { | ||
this.transport = options.transport | ||
} else { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filipecabaco It seems like this type isn't being used, but what is it for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will check with @w3b6x9 🤔