mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Added an optional options parameter for WebSockets
Summary: This enables overriding origin, and other request headers. Similar to the https://github.com/websockets/ws api. Closes https://github.com/facebook/react-native/pull/4629 Reviewed By: svcscm Differential Revision: D2839951 Pulled By: mkonicek fb-gh-sync-id: 3578af4343f90572b8851ff28342a05945498ef6
This commit is contained in:
committed by
facebook-github-bot-4
parent
15f806957f
commit
9b87e6c860
@@ -26,15 +26,16 @@ var CLOSE_NORMAL = 1000;
|
||||
* Browser-compatible WebSockets implementation.
|
||||
*
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
|
||||
* See https://github.com/websockets/ws
|
||||
*/
|
||||
class WebSocket extends WebSocketBase {
|
||||
_socketId: number;
|
||||
_subs: any;
|
||||
|
||||
connectToSocketImpl(url: string): void {
|
||||
connectToSocketImpl(url: string, protocols: ?Array<string>, options: ?{origin?: string}): void {
|
||||
this._socketId = WebSocketId++;
|
||||
|
||||
RCTWebSocketModule.connect(url, this._socketId);
|
||||
RCTWebSocketModule.connect(url, protocols, options, this._socketId);
|
||||
|
||||
this._registerEvents(this._socketId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user