btw, here is the netention web server code:
https://github.com/automenta/netjs/blob/master/server/web.js
sorry it's a bit of a mess combining DB (mongodb), express, socket.io setup, and all the API calls in one file. here's a list of the key functions:
loads (at startup) and saves (periodically) system metadata in the database
function loadState,
function saveState
for the server processes new data, coming from client or another server; usually results in add to database
function notice(o, whenFinished, fromSocket) {
function noticeAll(objList) -
delete functions
function deleteObject(objectID, whenFinished, contentAddedToDeletedObject, byClientID) {
function deleteObjects(objs, whenFinished) {
function deleteObjectsWithTag(tag, callback) {
query
function getObjectByID(uri, whenFinished) {
function getObjectsByAuthor(a, withObjects) {
function getObjectsByTag(t, withObject, whenFinished) {
function getLatestObjects(n, withObjects, withError) {
function getExpiredObjects(withObjects) {
users can have multiple profiles/personas:
function addClientSelf(req, uid) {
function getCurrentClientID(req) {
function getClientSelves(req) {
socket.on('become', function(target, _onResult) { when client first login or switches identity
socket.on('disconnect', function() { client disconnect
multi-level scope system for deciding who can access what object: public, trusted, private
function objCanSendTo(o, cid) { implements the
sends new or updated object to all clients and plugins
function broadcast(socket, o, whenFinished) {
when clients publish via websocket
socket.on('pub', function(message, err, success) {
when client attempts to delete an object (by ID)
socket.on('delete', function(objectID, whenFinished) {
current ontology for a client to load on startup
express.get('/ontology/:format', function(req, res) {
wikipedia proxy for selecting tags on live wikipages
express.get('/wiki/search/:query', compression, function(req, rres) {
express.get('/wiki/:tag/html', compression, function(req, rres) {
express.get('/wiki/:tag1/:tag2/html', compression, function(req, rres) {
webrtc roster
function updateUserConnection(oldID, nextID, socket) {
function setUserWebRTC(userID, webrtcID, enabled) {
socket.on('webRTC', function(id, enabled) {
server chat post in specific channel
socket.on('channelSend', function(channel, message) {