Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- define(
- [
- '../system/jobFactory',
- '../services/metadata',
- '../services/data',
- '../services/dataExecution',
- '../services/dataAcquisition',
- '../services/hrcDataAcquisition',
- '../services/adhocDataAcquisition',
- '../services/dataExport',
- '../security/authentication',
- '../system/frontEndLogger',
- '../security/connections',
- '../services/properties',
- '../services/config',
- '../db/db',
- '../system/packetFactory',
- '../services/fileReader',
- '../system/modulify',
- '../system/logger2',
- '../security/externalLogin',
- '../security/sanitizer',
- '../integration/scheduler'
- ],
- function(
- jobs,
- metadata,
- data,
- dataExecution,
- dataAcquisition,
- hrcDataAcquisition,
- adhocDataAcquisition,
- dataExport,
- authentication,
- frontEndLogger,
- connections,
- properties,
- config,
- db,
- packetFactory,
- fileReader,
- modulify,
- logger,
- externalLogin,
- sanitizer,
- scheduler
- ) {
- return modulify({
- endpoints: {
- /******** DATA *********/
- dataExecution: dataExecution.queue.bind(dataExecution),
- dataAcquisition: dataAcquisition.queue.bind(dataAcquisition),
- hrcDataAcquisition: hrcDataAcquisition.queue.bind(hrcDataAcquisition),
- setParameter: data.setParameter.bind(data),
- adhocDataAcquisition: adhocDataAcquisition.queue.bind(adhocDataAcquisition),
- dataExport: dataExport.queue.bind(dataExport),
- /******** PROPERTIES*********/
- getTypeProperties: properties.getTypeProperties.bind(properties),
- /******** CONNECTIONS*********/
- closePrc: connections.closePrc.bind(connections),
- openIpl: connections.openIpl.bind(connections),
- closeIpl: connections.closeIpl.bind(connections),
- showIpl: connections.showIpl.bind(connections),
- hideIpl: connections.hideIpl.bind(connections),
- reconnect: connections.reconnect.bind(connections),
- /******** ???????????*********/
- remoteDataAcquisition: data.remoteDataAcquisition.bind(data),
- /******** Integration*********/
- extLogin: externalLogin.refreshConnectObjects.bind(externalLogin),
- extValToken: externalLogin.checkTokenTable.bind(externalLogin),
- /******* METADATA*******/
- getMetadata: metadata.getMetadata.bind(metadata),
- login: authentication.initializeLicense.bind(authentication),
- register: authentication.register.bind(authentication),
- updatePassword: authentication.updatePassword.bind(authentication),
- getOrgGroups: authentication.getOrgGroups.bind(authentication),
- getImgFileList: fileReader.getImgFileList.bind(fileReader),
- uploadImage: fileReader.uploadImage.bind(fileReader),
- validateLicense: authentication.validateLicense.bind(authentication),
- /******* ERROR LOGGER *******/
- logError: frontEndLogger.logError.bind(frontEndLogger),
- /******* USER TRACKER *********/
- subscribeToMessages: userTracker.subscribe.bind(userTracker),
- /******** INTEGRATION *********/
- scheduleIntegration: scheduler.schedule.bind(scheduler)
- },
- route: function(socket, msg) {
- //TODO: Do we need to save the last action timestamp here?
- var endpoint = this.endpoints[msg.endpoint];
- if (!endpoint) {
- logger.error('NO ENDPOINT !!! THIS Should never happen - !@!!!!@@@#@$@#');
- return;
- }
- sanitizer.sanitizeData(msg.data);
- msg.data.socket = socket;
- msg.data.fromClient = true;
- // check if the users session is still valid
- // update the last action timestamp
- // is the session has expired redirect the user to the login screen
- var user = connections.getConnectionFromSocket(socket.id);
- if (user.authenticated) {
- //TODO: Change this to use a job and the que
- var spOptions = {
- spName: 'inf_pcd_aut_ssn_chk',
- spPars: {
- usr: user.usr,
- org: user.org,
- grp: user.grp,
- token: user.token,
- que: 0
- }
- };
- db.executeProcedure(spOptions, this.onSessionChecked.bind(this, endpoint, msg, socket, user));
- } else {
- jobs.startJob(endpoint, msg.data, msg.callback, user);
- }
- },
- onSessionChecked: function(endpoint, msg, socket, user, result) {
- if (result[0][0].sessionExpired == 1) {
- socket.emit('response', packetFactory.buildPacket({
- type: 'handshake',
- data: null,
- callback: {
- type: 'Client',
- method: 'goToLogin'
- }
- }));
- } else
- jobs.startJob(endpoint, msg.data, msg.callback, user);
- }
- }, 'router');
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement