1
0
Fork 0
mirror of git://git.psyced.org/git/psyced synced 2024-08-15 03:25:10 +00:00
psyced/world/net/psyc/active.c

94 lines
2.5 KiB
C
Raw Normal View History

// vim:foldmethod=marker:syntax=lpc:noexpandtab
2009-01-26 20:12:53 +00:00
// $Id: active.c,v 1.41 2008/06/17 09:35:45 lynx Exp $
//
2009-01-26 20:12:53 +00:00
#include "common.h"
#include <net.h>
#include <services.h>
2009-03-03 15:28:17 +00:00
#ifdef SPYC
inherit SPYC_PATH "circuit";
#else
inherit PSYC_PATH "circuit";
2009-03-03 15:28:17 +00:00
#endif
inherit NET_PATH "circuit";
volatile object super;
void takeover() {
super = previous_object();
if (super == ME) /* TODO: prevent elsewhere */ {
super = 0;
}
unless (interactive(ME)) runQ();
}
// we love multiple inheritance.. rock'n'roll!
int logon(int failure) {
int ret;
P2(("%O logon kriegt %O, prev: %O\n", ME, failure, previous_object()))
ret = NET_PATH "circuit"::logon(failure);
if (failure >= 0 && ret > 0) {
#if 0 // apparently wrong
emit(".\n"); // should we do the greeting?
PSYC_PATH "circuit"::logon(failure);
peeraddr = peerhost = host;
if (port && port != PSYC_SERVICE) peeraddr += ":"+port;
#else // probably better
peeraddr = peerhost = host;
peerport = port;
if (port && port != PSYC_SERVICE) peeraddr += ":"+port;
// circuit::logon now also implies a full greeting
// therefore it needs peeraddr, and the emit is redundant
2009-03-03 15:28:17 +00:00
# ifdef SPYC
SPYC_PATH "circuit"::logon(failure);
# else
PSYC_PATH "circuit"::logon(failure);
2009-03-03 15:28:17 +00:00
# endif
#endif
return 1;
}
return 0;
}
int msg(string source, string method, string data,
mapping vars, int showingLog, string target) {
P3(("active.c:msg(%O, %O, %O) in %O%s\n", source, method, data, ME,
(interactive()) ? "(connected)" : "(not connected)"))
unless (interactive()) {
2009-12-31 18:28:27 +00:00
P2(("%O is not interactive (no network connection)\n", ME))
if (!member(vars, "_source"))
vars["_source"] = UNIFORM(source);
// this stuff is causing loops and i don't know how to fix it right now
// unless (super)
# ifdef SPYC
// NOTE: SPYC uses a per-host verification and therefore
// may not send certain packets before verification
// is done (those packets usually have source and target)
// for now, this check works most of the time
# endif
return enqueue(source, method, data, vars, showingLog, target);
// return super->msg(source, method, data, vars, showingLog, target);
}
return ::msg(source, method, data, vars, showingLog, target);
}
#if 0
connect(host, port) {
if (host) {
// funky but who needs this?
if (interactive()) {
if (ahost == host && aport == port) return -8;
else remove_interactive(ME);
}
...
P1(("PSYC/TCP %O * net_connect(%O, %O) = %O\n",
ME, host, port, rc))
return rc;
}
#endif