diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2017-11-28 06:34:34 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2017-11-28 06:34:34 +0800 |
commit | 426a412ba1a0e3cd955d11bbe6d7426a61e5dd63 (patch) | |
tree | 5d3e9f2749411ba91fa567f96ce81d1206d273be /packages/connect/src/ws_orderbook_channel.ts | |
parent | 4a17f5e82074b01e74ae6982e82419a037eebdb4 (diff) | |
download | dexon-0x-contracts-426a412ba1a0e3cd955d11bbe6d7426a61e5dd63.tar dexon-0x-contracts-426a412ba1a0e3cd955d11bbe6d7426a61e5dd63.tar.gz dexon-0x-contracts-426a412ba1a0e3cd955d11bbe6d7426a61e5dd63.tar.bz2 dexon-0x-contracts-426a412ba1a0e3cd955d11bbe6d7426a61e5dd63.tar.lz dexon-0x-contracts-426a412ba1a0e3cd955d11bbe6d7426a61e5dd63.tar.xz dexon-0x-contracts-426a412ba1a0e3cd955d11bbe6d7426a61e5dd63.tar.zst dexon-0x-contracts-426a412ba1a0e3cd955d11bbe6d7426a61e5dd63.zip |
Move all connect types into types.ts
Diffstat (limited to 'packages/connect/src/ws_orderbook_channel.ts')
-rw-r--r-- | packages/connect/src/ws_orderbook_channel.ts | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/packages/connect/src/ws_orderbook_channel.ts b/packages/connect/src/ws_orderbook_channel.ts index 78b823dbe..769a52237 100644 --- a/packages/connect/src/ws_orderbook_channel.ts +++ b/packages/connect/src/ws_orderbook_channel.ts @@ -8,20 +8,11 @@ import { OrderbookChannelHandler, OrderbookChannelMessageTypes, OrderbookChannelSubscriptionOpts, + WebsocketClientEventType, + WebsocketConnectionEventType, } from './types'; import {orderbookChannelMessageParsers} from './utils/orderbook_channel_message_parsers'; -enum ConnectionEventType { - Close = 'close', - Error = 'error', - Message = 'message', -} - -enum ClientEventType { - Connect = 'connect', - ConnectFailed = 'connectFailed', -} - /** * This class includes all the functionality related to interacting with a websocket endpoint * that implements the standard relayer API v0 @@ -63,13 +54,13 @@ export class WebSocketOrderbookChannel implements OrderbookChannel { if (!_.isUndefined(error)) { handler.onError(this, error); } else if (!_.isUndefined(connection) && connection.connected) { - connection.on(ConnectionEventType.Error, wsError => { + connection.on(WebsocketConnectionEventType.Error, wsError => { handler.onError(this, wsError); }); - connection.on(ConnectionEventType.Close, () => { + connection.on(WebsocketConnectionEventType.Close, () => { handler.onClose(this); }); - connection.on(ConnectionEventType.Message, message => { + connection.on(WebsocketConnectionEventType.Message, message => { this._handleWebSocketMessage(message, handler); }); connection.sendUTF(JSON.stringify(subscribeMessage)); @@ -88,11 +79,11 @@ export class WebSocketOrderbookChannel implements OrderbookChannel { if (!_.isUndefined(this.connectionIfExists) && this.connectionIfExists.connected) { callback(undefined, this.connectionIfExists); } else { - this.client.on(ClientEventType.Connect, connection => { + this.client.on(WebsocketClientEventType.Connect, connection => { this.connectionIfExists = connection; callback(undefined, this.connectionIfExists); }); - this.client.on(ClientEventType.ConnectFailed, error => { + this.client.on(WebsocketClientEventType.ConnectFailed, error => { callback(error, undefined); }); this.client.connect(this.apiEndpointUrl); |