-
Notifications
You must be signed in to change notification settings - Fork 933
Add forceWebSockets() and forceLongPolling() #6171
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3399b28
Implemented forceWebSockets() and forceLongPolling()
maneesht 8d0526b
Removed xit
maneesht 932f309
Added license
maneesht 83a6f85
Merge remote-tracking branch 'origin/master' into force-rtdb-transpor…
maneesht 30ad72f
Included APIs to database-compat
maneesht 927560b
Merge remote-tracking branch 'origin/master' into force-rtdb-transpor…
maneesht 7b0c2c5
Removed console log
maneesht f9bdf59
Updated tests
maneesht 8c1249b
Fixed formatting
maneesht 6b8fce9
Create lucky-items-wave.md
maneesht 1521d5d
Updated tests
maneesht 6da1223
Merge branch 'force-rtdb-transport-method' of https://github.com/fire…
maneesht 1a29c85
Fixed formatting
maneesht 6b44914
Addresed comments
maneesht 3d5ba48
Clarified comment
maneesht af11311
Fixed formattign
maneesht 1e1ccd3
Used warning instead of throwing error
maneesht 43fb0ce
Fixed formatting
maneesht 2e31c57
Addressed comments
maneesht File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@firebase/database-compat": patch | ||
"@firebase/database": patch | ||
--- | ||
|
||
Add forceWebSockets() and forceLongPolling() | ||
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. Can you add backticks to the two methods? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* @license | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { CONSTANTS } from '@firebase/util'; | ||
import { expect } from 'chai'; | ||
|
||
import { forceLongPolling, forceWebSockets } from '../src'; | ||
import { BrowserPollConnection } from '../src/realtime/BrowserPollConnection'; | ||
import { TransportManager } from '../src/realtime/TransportManager'; | ||
import { WebSocketConnection } from '../src/realtime/WebSocketConnection'; | ||
|
||
const transportInitError = | ||
'Transport has already been initialized. Please call this function before calling ref or setting up a listener'; | ||
describe('Force Transport', () => { | ||
const oldNodeValue = CONSTANTS.NODE_CLIENT; | ||
beforeEach(() => { | ||
CONSTANTS.NODE_CLIENT = false; | ||
}); | ||
afterEach(() => { | ||
// Resetting to old values | ||
TransportManager.globalTransportInitialized_ = false; | ||
CONSTANTS.NODE_CLIENT = oldNodeValue; | ||
BrowserPollConnection.forceAllow_ = false; | ||
BrowserPollConnection.forceDisallow_ = true; | ||
WebSocketConnection.forceDisallow_ = false; | ||
}); | ||
it('should enable websockets and disable longPolling', () => { | ||
expect(forceWebSockets).to.not.throw(); | ||
expect(WebSocketConnection.isAvailable()).to.equal(true); | ||
expect(BrowserPollConnection.isAvailable()).to.equal(false); | ||
}); | ||
it('should throw an error when calling forceWebsockets() if TransportManager has already been initialized', () => { | ||
TransportManager.globalTransportInitialized_ = true; | ||
expect(forceWebSockets).to.throw(transportInitError); | ||
expect(WebSocketConnection.isAvailable()).to.equal(true); | ||
expect(BrowserPollConnection.isAvailable()).to.equal(false); | ||
}); | ||
it('should enable longPolling and disable websockets', () => { | ||
expect(forceLongPolling).to.not.throw(); | ||
expect(WebSocketConnection.isAvailable()).to.equal(false); | ||
expect(BrowserPollConnection.isAvailable()).to.equal(true); | ||
}); | ||
it('should throw an error when calling forceLongPolling() if TransportManager has already been initialized', () => { | ||
TransportManager.globalTransportInitialized_ = true; | ||
expect(forceLongPolling).to.throw(transportInitError); | ||
expect(WebSocketConnection.isAvailable()).to.equal(true); | ||
expect(BrowserPollConnection.isAvailable()).to.equal(false); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is an API change so I think these should both be "minor" bumps.