UNPKG

jspurefix

Version:
79 lines 2.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FixmlSession = void 0; const FIXML50SP2_1 = require("../../types/FIXML50SP2"); const types_1 = require("../../types"); const fix_session_1 = require("../session/fix-session"); const session_state_1 = require("../session/session-state"); class FixmlSession extends fix_session_1.FixSession { constructor(config) { super(config); this.config = config; this.requestLogoutType = 'UserReq'; this.requestLogonType = 'UserReq'; this.respondLogoutType = 'UserRsp'; } onMsg(msgType, view) { switch (msgType) { case 'UserReq': case 'UserRsp': { this.onSessionMsg(msgType, view); break; } default: { this.checkForwardMsg(msgType, view); break; } } } onSessionMsg(msgType, view) { switch (msgType) { case 'UserReq': { const reqType = view.getTyped('UserReqTyp'); switch (reqType) { case FIXML50SP2_1.UserRequestType.LogOnUser: { this.peerLogon(view); break; } case FIXML50SP2_1.UserRequestType.LogOffUser: { this.peerLogout(view); break; } } break; } case 'UserRsp': { const userStatus = view.getTyped('UserStatus'); switch (userStatus) { case FIXML50SP2_1.UserStatus.LoggedIn: { this.peerLogon(view); break; } case FIXML50SP2_1.UserStatus.NotLoggedIn: { this.peerLogout(view); break; } } break; } } } peerLogon(view) { var _a, _b, _c; const logger = this.sessionLogger; const state = this.sessionState; state.state = session_state_1.SessionState.InitiationLogonReceived; state.peerCompId = view.getTyped(types_1.MsgTag.SenderCompID); if (this.acceptor) { const reqId = (_a = view.getString('UserReqID')) !== null && _a !== void 0 ? _a : 'req'; const o = (_c = (_b = this === null || this === void 0 ? void 0 : this.config) === null || _b === void 0 ? void 0 : _b.factory) === null || _c === void 0 ? void 0 : _c.logon(reqId, true); if (o) { this.send('UserRsp', o); } } logger.info('system ready, inform app'); this.onReady(view); } } exports.FixmlSession = FixmlSession; //# sourceMappingURL=fixml-session.js.map