Consolidate Viewdata/ANSItex specific modules to use consistent method names, our session is now initialised at startup as either

This commit is contained in:
Deon George 2023-12-26 09:17:19 +11:00
parent 701dd9f5e8
commit 7b34decb49
4 changed files with 22 additions and 29 deletions

View File

@ -129,10 +129,10 @@ const FRAME_SAVE_ATTRS = [
];
/* The page that has our echomail area reading template */
const MAIL_TEMPLATE_FRAME = '199a';
const MAIL_TEMPLATE_FRAME = {frame: 199,index: 'a'};
/* The page that has our echomail area summary template */
const MAIL_TEMPLATE_AREA_SUMMARY = '198a';
const MAIL_TEMPLATE_AREA_SUMMARY = {frame: 198,index: 'a'};
// The maximum size of embedded dynamic fields in frames
const DYNAMIC_FIELD_SIZE_MAX = 50;

View File

@ -431,7 +431,7 @@ function rawtoattrs(contents,width,yoffset,xoffset,debug) {
load('ansitex/load/session.js');
// Our frame object
function SessionAnsitex() {
function SessionProtocol() {
Session.apply(this,arguments);
this.settings.MSG_SENDORNOT = '\1n\1h\1GKEY 1 TO SEND, 2 NOT TO SEND';
@ -590,5 +590,5 @@ function SessionAnsitex() {
};
}
SessionAnsitex.prototype = Session.prototype;
SessionAnsitex.prototype.constructor = SessionAnsitex;
SessionProtocol.prototype = Session.prototype;
SessionProtocol.prototype.constructor = SessionProtocol;

View File

@ -435,7 +435,7 @@ function rawtoattrs(contents,width,yoffset,xoffset,debug) {
load('ansitex/load/session.js');
// Our frame object
function SessionViewdata() {
function SessionProtocol() {
Session.apply(this,arguments);
this.settings.MSG_SENDORNOT = ascii(27)+'BKEY 1 TO SEND, 2 NOT TO SEND';
@ -674,5 +674,5 @@ function videotex(data) {
return output;
}
SessionViewdata.prototype = Session.prototype;
SessionViewdata.prototype.constructor = SessionViewdata;
SessionProtocol.prototype = Session.prototype;
SessionProtocol.prototype.constructor = SessionProtocol;

35
main.js
View File

@ -8,20 +8,15 @@
log(LOG_DEBUG,'* INIT: ANSItex');
// SBBS General definitions
require('sbbsdefs.js','SS_USERON');
// SBBS Key definitions
require('key_defs.js','KEY_ESC');
// ANSItex specific includes
load('ansitex/load/funcs.js');
load('ansitex/load/msgbases.js');
// Our page handler
load('ansitex/load/page.js');
require('ansitex/load/defs.js','ACTION_EXIT');
// @todo Returning from chat should refresh the frame
// @todo Suppress displays of telegrams (but trigger when they arrive)
/**
@ -35,6 +30,9 @@ bbs.node_settings &= NM_NO_INACT;
bbs.node_settings &= NM_NOPAUSESPIN;
// Dont allow users to login with a number
bbs.node_settings &= NM_NO_NUM;
// @todo Suppress "Read your mail now" at login
// @todo Update message loading to process mystic color codes - this todo shouldnt be here, but placed here so I would see it and move it
// @todo Add "time ago" for messages, as an easier visual of how old it is.
// Suppress some SBBS message prompts, as we handle them
bbs.replace_text(390,''); // Unknown User
@ -51,11 +49,6 @@ switch (client.socket.local_port) {
require('ansitex/load/session/ansitex.js','SESSION_ANSITEX');
}
// @todo Suppress "Read your mail now" at login
// @todo Update message loading to process mystic color codes - this todo shouldnt be here, but placed here so I would see it and move it
// @todo Add "time ago" for messages, as an easier visual of how old it is.
bbs.node_settings &= ~(NM_LOGON_P); // Dont always ask for a password.
/**
* This is our main event loop - where we interact with the user.
* This loop takes care of first connect (unauthenticated users), or after authentication (main shell).
@ -93,9 +86,9 @@ while (bbs.online) {
* Current Session Object that describe the terminal that the user has connected on
* - SessionViewdata - for ViewData sessions
* - SessionAnsitex - for ANSItex sessions
* @type {SessionAnsitex|SessionViewdata|null}
* @type {SessionProtocol}
*/
var so = null;
var so = new SessionProtocol();
/**
* History of PageObjects that the user has seen this session
@ -939,7 +932,7 @@ while (bbs.online) {
// If we are editing a specific frame, attempt to load it
if (next_page) {
var current = so;
so = (SESSION_EXT === 'vtx') ? new SessionViewdata() : new SessionAnsitex();
//so = (SESSION_EXT === 'vtx') ? new SessionViewdata() : new SessionAnsitex();
so.get(next_page);
// If the frame doesnt exist, check that the parent frame exists in case we are creating a new one
@ -962,7 +955,7 @@ while (bbs.online) {
}
// New frame
so = (SESSION_EXT === 'vtx') ? new SessionViewdata() : new SessionAnsitex();
//so = (SESSION_EXT === 'vtx') ? new SessionViewdata() : new SessionAnsitex();
so.frame = next_page.frame;
so.index = next_page.index;
so.cost = 0;
@ -1011,9 +1004,9 @@ while (bbs.online) {
if (/^1[0-9]{6}1$/.test(next_page.frame)) {
log(LOG_DEBUG,'- ACTION_GOTO - load echoarea summary: ['+next_page.frame+']');
to = (SESSION_EXT === 'vtx') ? new SessionViewdata() : new SessionAnsitex();
//to = (SESSION_EXT === 'vtx') ? new SessionViewdata() : new SessionAnsitex();
// @todo look for a template in the area or group first
to.load(MAIL_TEMPLATE_AREA_SUMMARY);
to.get(new PageObject(MAIL_TEMPLATE_AREA_SUMMARY));
var ma = new MsgAreas();
var area = ma.getArea(next_page.frame);
@ -1027,7 +1020,7 @@ while (bbs.online) {
current = so;
so = (SESSION_EXT === 'vtx') ? new SessionViewdata() : new SessionAnsitex();
//so = (SESSION_EXT === 'vtx') ? new SessionViewdata() : new SessionAnsitex();
so.frame = next_page.frame;
so.index = next_page.index;
so.content = to.content;
@ -1056,7 +1049,7 @@ while (bbs.online) {
if (next_page.index === 'a') {
require('ansitex/load/control/echomail.js','CONTROL_ECHOMAIL');
control.push(new echomail(next_page.frame));
control.push(new echomail(next_page.frame,so));
action = null;
next_page = null;
log(LOG_DEBUG,'- ACTION_GOTO - control message: ['+JSON.stringify(control[control.length-1])+'] ('+control.length+')');
@ -1090,7 +1083,7 @@ while (bbs.online) {
if (next_page !== null) {
current = so;
so = (SESSION_EXT === 'vtx') ? new SessionViewdata() : new SessionAnsitex();
//so = (SESSION_EXT === 'vtx') ? new SessionViewdata() : new SessionAnsitex();
log(LOG_DEBUG,'**** Got: ['+JSON.stringify(next_page)+']');
so.get(next_page);
log(LOG_DEBUG,' - Got: ['+so.page.name.toString()+']');
@ -1100,8 +1093,8 @@ while (bbs.online) {
so = current;
// In case the frame doesnt exist
if (so === null)
so = (SESSION_EXT === 'vtx') ? new SessionViewdata() : new SessionAnsitex();
//if (so === null)
// so = (SESSION_EXT === 'vtx') ? new SessionViewdata() : new SessionAnsitex();
// sendbaseline ERR_PAGE
so.baselineSend('ERR_ROUTE',false);