diff --git a/CHANGELOG.md b/CHANGELOG.md index ea1cc60520..1e80c8145f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. The changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [1.0.0] - 13-Mar-2021 + +**Milestone**: Symbol Mainnet + Package | Version | Link +---|---|--- +SDK Core| v1.0.0 | [symbol-sdk](https://www.npmjs.com/package/symbol-sdk) +Catbuffer | v0.1.1 | [catbuffer-typescript](https://www.npmjs.com/package/catbuffer-typescript) +Client Library | v0.11.1 | [symbol-openapi-typescript-fetch-client](https://www.npmjs.com/package/symbol-openapi-typescript-fetch-client) + +- Added callback function in websocket listener for client to handle unsolicited websocket close event. +- Release for Symbol mainnet. + ## [0.23.3] - 5-Mar-2021 **Milestone**: Catapult-server main(0.10.0.8) diff --git a/package-lock.json b/package-lock.json index c86b1854dd..f428f7b8a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "symbol-sdk", - "version": "0.23.4", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e2a4882541..28d383096e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "symbol-sdk", - "version": "0.23.4", + "version": "1.0.0", "description": "Reactive symbol sdk for typescript and javascript", "scripts": { "pretest": "npm run build", diff --git a/src/infrastructure/IListener.ts b/src/infrastructure/IListener.ts index 92b0c7bede..2d5ca0a4ad 100644 --- a/src/infrastructure/IListener.ts +++ b/src/infrastructure/IListener.ts @@ -23,6 +23,8 @@ import { CosignatureSignedTransaction } from '../model/transaction/CosignatureSi import { Transaction } from '../model/transaction/Transaction'; import { TransactionStatusError } from '../model/transaction/TransactionStatusError'; +export type OnWsCloseCallback = (event: { client: string; code: any; reason: any }) => void; + /** * Listener service */ @@ -35,7 +37,7 @@ export interface IListener { * Open web socket connection. * @returns Promise */ - open(): Promise; + open(onUnsolicitedCloseCallback?: OnWsCloseCallback): Promise; /** * returns a boolean that repressents the open state diff --git a/src/infrastructure/Listener.ts b/src/infrastructure/Listener.ts index 800e85cb58..878209d1a7 100644 --- a/src/infrastructure/Listener.ts +++ b/src/infrastructure/Listener.ts @@ -29,7 +29,7 @@ import { Deadline } from '../model/transaction/Deadline'; import { Transaction } from '../model/transaction/Transaction'; import { TransactionStatusError } from '../model/transaction/TransactionStatusError'; import { UInt64 } from '../model/UInt64'; -import { IListener } from './IListener'; +import { IListener, OnWsCloseCallback } from './IListener'; import { MultisigHttp } from './MultisigHttp'; import { MultisigRepository } from './MultisigRepository'; import { NamespaceRepository } from './NamespaceRepository'; @@ -109,7 +109,7 @@ export class Listener implements IListener { * Open web socket connection. * @returns Promise */ - public open(): Promise { + public open(onUnsolicitedCloseCallback?: OnWsCloseCallback): Promise { return new Promise((resolve, reject) => { if (this.webSocket === undefined || this.webSocket.readyState === this.webSocket.CLOSED) { if (this.websocketInjected) { @@ -127,11 +127,16 @@ export class Listener implements IListener { return; } if (closeEvent) { - reject({ + const event = { client: this.uid, code: closeEvent.code, reason: closeEvent.reason, - }); + }; + if (onUnsolicitedCloseCallback) { + onUnsolicitedCloseCallback(event); + } else { + reject(event); + } } }; this.webSocket.onmessage = (msg: any): void => {