|
18 | 18 | */
|
19 | 19 | import BoltProtocolV4 from './bolt-protocol-v4x0'
|
20 | 20 | import RequestMessage, { ALL } from './request-message'
|
21 |
| -import { ResultStreamObserver } from './stream-observers' |
22 | 21 | import { BOLT_PROTOCOL_V4_1 } from './constants'
|
| 22 | +import { LoginObserver } from './stream-observers' |
23 | 23 |
|
24 | 24 | export default class BoltProtocol extends BoltProtocolV4 {
|
| 25 | + /** |
| 26 | + * @constructor |
| 27 | + * @param {Connection} connection the connection. |
| 28 | + * @param {Chunker} chunker the chunker. |
| 29 | + * @param {boolean} disableLosslessIntegers if this connection should convert all received integers to native JS numbers. |
| 30 | + * @param {Object} serversideRouting |
| 31 | + */ |
| 32 | + constructor (connection, chunker, disableLosslessIntegers, serversideRouting) { |
| 33 | + super(connection, chunker, disableLosslessIntegers) |
| 34 | + this._serversideRouting = serversideRouting |
| 35 | + } |
| 36 | + |
25 | 37 | get version () {
|
26 | 38 | return BOLT_PROTOCOL_V4_1
|
27 | 39 | }
|
| 40 | + |
| 41 | + initialize ({ userAgent, authToken, onError, onComplete } = {}) { |
| 42 | + const observer = new LoginObserver({ |
| 43 | + connection: this._connection, |
| 44 | + afterError: onError, |
| 45 | + afterComplete: onComplete |
| 46 | + }) |
| 47 | + |
| 48 | + this._connection.write( |
| 49 | + RequestMessage.hello(userAgent, authToken, this._serversideRouting), |
| 50 | + observer, |
| 51 | + true |
| 52 | + ) |
| 53 | + |
| 54 | + return observer |
| 55 | + } |
28 | 56 | }
|
0 commit comments