Skip to content

Commit 1d004a0

Browse files
Add options for websocket connectivity
1 parent 975c0ca commit 1d004a0

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ export interface SQLiteCloudConfig {
4747
/** Custom options and configurations for tls socket, eg: additional certificates */
4848
tlsOptions?: tls.ConnectionOptions
4949

50+
/** Custom options and configurations for socket.io connections */
51+
websocketOptions?: {
52+
/** True if we should force use of SQLite Cloud Gateway and websocket connections, default: true in browsers, false in node.js */
53+
useWebsocket?: boolean
54+
/** Url where we can connect to a SQLite Cloud Gateway that has a socket.io deamon waiting to connect, eg. ws://host:4000 */
55+
gatewayUrl?: string
56+
}
57+
5058
/** Optional identifier used for verbose logging */
5159
clientId?: string
5260
/** True if connection should enable debug logs */

test/connection-ws.test.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,13 @@ describe('connection-ws', () => {
5454

5555
it('should connect with config object string', done => {
5656
const configObj = getChinookConfig()
57-
const conn = new SQLiteCloudWebsocketConnection(configObj, error => {
58-
expect(error).toBeNull()
59-
expect(conn.connected).toBe(true)
60-
61-
chinook.sendCommands('TEST STRING', (error, results) => {
62-
conn.close()
63-
expect(conn.connected).toBe(false)
64-
done()
65-
})
57+
const connection = new SQLiteCloudWebsocketConnection(configObj)
58+
expect(connection).toBeDefined()
59+
connection.sendCommands('TEST STRING', (error, results) => {
60+
connection.close()
61+
expect(connection.connected).toBe(false)
62+
done()
6663
})
67-
expect(conn).toBeDefined()
6864
})
6965

7066
it('should connect with connection string', done => {

0 commit comments

Comments
 (0)