Skip to content
Permalink
Browse files

v0.4.20

  • Loading branch information...
scripting committed Sep 6, 2019
1 parent bb0fe87 commit 38504e097ec2df29b2c242bac3d452ae23a808d2
Showing with 9 additions and 42 deletions.
  1. +5 −39 examples/mailservice/mailservice.js
  2. +2 −1 examples/mailservice/package.json
  3. +1 −1 package.json
  4. +1 −1 xmlrpc.js
@@ -1,52 +1,21 @@
const xmlrpc = require ("./lib/xmlrpc.js");
const xmlrpc = require ("davexmlrpc");
const utils = require ("daveutils");
const davehttp = require ("davehttp");
const mail = require ("davemail");
const persists = require ("persists");
const fs = require ("fs");

var config = {
port: 1417,
flPostEnabled: true,
flLogToConsole: true,
xmlRpcPath: "/rpc2",
archiveFolder: "data/archive/",
fnameStats: "data/stats.json"
archiveFolder: "data/archive/"
}
var stats = {
const initialStats = {
fileSerialnum: 0
};
var flStatsChanged = false;

function statsChanged () {
flStatsChanged = true;
}
function readStats (callback) {
fs.readFile (config.fnameStats, function (err, data) {
if (!err) {
try {
var jstruct = JSON.parse (data);
for (var x in jstruct) {
stats [x] = jstruct [x];
}
}
catch (err) {
}
}
callback ();
});
}
function everySecond () {
if (flStatsChanged) {
flStatsChanged = false;
utils.sureFilePath (config.fnameStats, function () {
fs.writeFile (config.fnameStats, utils.jsonStringify (stats), function (err) {
});
});
}
}

setInterval (everySecond, 1000);
readStats (function () {
persists ("stats", initialStats, undefined, function (stats) {
xmlrpc.startServerOverHttp (config, function (xmlRpcRequest) {
function mailSend (params, callback) {
var recipient = params [0];
@@ -64,7 +33,6 @@ readStats (function () {
obj.err = err;
}
var f = config.archiveFolder + utils.getDatePath (now) + utils.padWithZeros (stats.fileSerialnum++, 4) + ".json";
statsChanged ();
utils.sureFilePath (f, function () {
fs.writeFile (f, utils.jsonStringify (obj), function (err) {
});
@@ -79,5 +47,3 @@ readStats (function () {
return (false); //we didn't handle it
});
});


@@ -8,6 +8,7 @@
"daveutils": "*",
"davehttp": "*",
"davemail": "*",
"davexmlrpc": "*"
"davexmlrpc": "*",
"persists": "*"
}
}
@@ -3,7 +3,7 @@
"description": "XML-RPC client and server in JavaScript.",
"author": "Dave Winer <dave@smallpicture.com>",
"license": "MIT",
"version": "0.4.19",
"version": "0.4.20",
"main": "xmlrpc.js",
"repository": {
"type": "git",
@@ -1,4 +1,4 @@
var myProductName = "xmlrpc"; myVersion = "0.4.19";
var myProductName = "xmlrpc"; myVersion = "0.4.20";

exports.client = xmlRpcClient;
exports.server = xmlRpcServer;

0 comments on commit 38504e0

Please sign in to comment.
You can’t perform that action at this time.