From dd251994eab0306ca932d858dce80a152458e2e7 Mon Sep 17 00:00:00 2001 From: Vijay Kumar Date: Wed, 8 Sep 2021 01:33:30 +0530 Subject: [PATCH 1/5] Added payeeapp simulator --- src/index.js | 2 + .../PayeeAppSimulator/payeeNotifications.js | 62 +++++++ src/views/demos/Demos.jsx | 14 ++ .../demos/PayeeAppSimulator/PayeeApp.jsx | 168 ++++++++++++++++++ 4 files changed, 246 insertions(+) create mode 100644 src/services/demos/PayeeAppSimulator/payeeNotifications.js create mode 100644 src/views/demos/PayeeAppSimulator/PayeeApp.jsx diff --git a/src/index.js b/src/index.js index 89434b15..7d7392b6 100644 --- a/src/index.js +++ b/src/index.js @@ -35,6 +35,7 @@ import 'antd/dist/antd.css'; import Login from './views/login/Login.jsx'; import MobileSimulator from "./views/demos/MobileSimulator/MobileSimulator.jsx"; +import PayeeAppSimulator from "./views/demos/PayeeAppSimulator/PayeeApp"; import DemoTestRunner from "./views/demos/DemoTestRunner/DemoTestRunner.jsx"; @@ -98,6 +99,7 @@ function App() { } /> } /> + } /> } /> diff --git a/src/services/demos/PayeeAppSimulator/payeeNotifications.js b/src/services/demos/PayeeAppSimulator/payeeNotifications.js new file mode 100644 index 00000000..1dda9eef --- /dev/null +++ b/src/services/demos/PayeeAppSimulator/payeeNotifications.js @@ -0,0 +1,62 @@ +/***** + License + -------------- + Copyright © 2017 Bill & Melinda Gates Foundation + The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + Contributors + -------------- + This is the official list of the Mojaloop project contributors for this file. + Names of the original copyright holders (individuals or organizations) + should be listed with a '*' in the first column. People who have + contributed from an organization can be listed under the organization + that actually holds the copyright for their contributions (see the + Gates Foundation organization for an example). Those individuals should have + their names indented and be marked with a '-'. Email address can be added + optionally within square brackets . + * Gates Foundation + + * ModusBox + * Vijaya Kumar Guthi (Original Author) + -------------- + ******/ + +import socketIOClient from "socket.io-client"; +import { getConfig } from '../../../utils/getConfig' + +class NotificationService { + + notificationEventFunction = () => {} + + setNotificationEventListener (notificationEventFunction) { + this.notificationEventFunction = notificationEventFunction + } + + apiBaseUrl = '' + sessionId = '' + socket = null + socketTopic = 'pushMessage' + + constructor (sessionId = null) { + const { apiBaseUrl } = getConfig() + this.apiBaseUrl = apiBaseUrl + this.sessionId = sessionId + + this.socket = socketIOClient(this.apiBaseUrl) + this.socket.on(this.socketTopic + (this.sessionId ? '/' + this.sessionId : ''), message => { + this.notificationEventFunction(message) + }) + } + + getSessionId () { + return this.sessionId + } + + disconnect () { + this.socket.disconnect() + } + +} + +export default NotificationService diff --git a/src/views/demos/Demos.jsx b/src/views/demos/Demos.jsx index 032281d1..b64fb9de 100644 --- a/src/views/demos/Demos.jsx +++ b/src/views/demos/Demos.jsx @@ -43,6 +43,20 @@ class Demos extends React.Component { + + + + +