|
| 1 | +// tslint:disable:no-console |
| 2 | +// tslint:disable-next-line: no-implicit-dependencies |
| 3 | +import { Pricing, Session } from '@refinitiv-data/data'; |
| 4 | +import { getSession } from '../../Common/session'; |
| 5 | + |
| 6 | +const session = getSession(); |
| 7 | + |
| 8 | +(async () => { |
| 9 | + try { |
| 10 | + console.log('Opening the session...'); |
| 11 | + // open the session |
| 12 | + await session.open(); |
| 13 | + console.log('Session open, sending data request'); |
| 14 | + |
| 15 | + // Get the list of all services available on the platform |
| 16 | + const sdDefinition = Pricing.ServiceDirectory.Definition(); |
| 17 | + |
| 18 | + // Get the list of serviceswhich match specified filter |
| 19 | + /* |
| 20 | + const sdDefinition = Pricing.ServiceDirectory.Definition({ |
| 21 | + extendedParams: { |
| 22 | + QoS: { |
| 23 | + Rate: 1000, |
| 24 | + Limit: 'Unlimited' |
| 25 | + } |
| 26 | + } |
| 27 | + }); |
| 28 | + */ |
| 29 | + |
| 30 | + const stream = sdDefinition.getStream(session); |
| 31 | + |
| 32 | + stream.onAdd(data => console.log('Add event:', data)); |
| 33 | + stream.onDelete(data => console.log('Delete event:', data)); |
| 34 | + stream.onUpdate(data => console.log('Update event:', data)); |
| 35 | + stream.onStatus(status => console.log('Status event:', status)); |
| 36 | + stream.onComplete(() => console.log('Complete!')); |
| 37 | + stream.onError(error => console.log('Error event:', error)); |
| 38 | + |
| 39 | + await stream.open(); |
| 40 | + // await stream.open({withUpdates: false}); |
| 41 | + |
| 42 | + console.log('Description by Name:', stream.getServiceDescription('ELEKTRON_DD')); |
| 43 | + console.log('Description by ID:', stream.getServiceDescription(257)); |
| 44 | + console.log('Definition property:', stream.definition); |
| 45 | + |
| 46 | + console.log('Streaming chain opened, waiting 20 seconds...'); |
| 47 | + await new Promise(res => setTimeout(res, 20000)); |
| 48 | + |
| 49 | + await stream.close(); |
| 50 | + } |
| 51 | + catch (err) { |
| 52 | + console.log(err); |
| 53 | + } |
| 54 | + finally { |
| 55 | + session.close(); |
| 56 | + } |
| 57 | +})(); |
0 commit comments