one mud per child.. unfinished integration

This commit is contained in:
psyc://loupsycedyglgamf.onion/~lynX 2016-07-20 18:50:52 +02:00
parent e6cd27632e
commit 4176e267d8
4 changed files with 92 additions and 15 deletions

View File

@ -1,11 +1,17 @@
#include <net.h> #include <net.h>
//#ifdef BRAIN
# define CONNECT_TELNET "nemesis.de", 2000 # define CONNECT_TELNET "nemesis.de", 2000
//#else
//# define CONNECT_TELNET "nemesis.de", 2001 // NemTest
//#endif
#define ON_CONNECT emit("guest\n"); #define ON_CONNECT emit("guest\n");
#define ON_ANY NET_PATH "tn/outgoing"::msg(source, mc, data, vars); #define ON_ANY NET_PATH "tn/outgoing"::msg(source, mc, data, vars);
#include <place.gen> #include <place.gen>
// to do this properly, we need a systematic way to redo prompts FIXME
parse(all) { parse(all) {
// remove Nemesis' guest prompt.. why was i so funny // remove Nemesis' guest prompt.. why was i so funny
// back then to implement several prompt chars? // back then to implement several prompt chars?

View File

@ -363,6 +363,11 @@ _notice_typing_active
_notice_typing_gone _notice_typing_gone
|<message to='[_INTERNAL_target_jabber]' from='[_INTERNAL_source_jabber]'><gone xmlns='http://jabber.org/protocol/chatstates'/></message> |<message to='[_INTERNAL_target_jabber]' from='[_INTERNAL_source_jabber]'><gone xmlns='http://jabber.org/protocol/chatstates'/></message>
_notice_telnet_verbatim
|<message from='[_INTERNAL_source_jabber_bare]' to='[_INTERNAL_target_jabber]' type='groupchat'>
| <body>[_text_verbatim]</body>
|</message>
_notice_place _notice_place
|<message from='[_INTERNAL_source_jabber_bare]' to='[_INTERNAL_target_jabber]' type='groupchat'> |<message from='[_INTERNAL_source_jabber_bare]' to='[_INTERNAL_target_jabber]' type='groupchat'>
| <body>[_data]</body> | <body>[_data]</body>

View File

@ -1,43 +1,73 @@
// vim:syntax=lpc // vim:syntax=lpc
// DEBUG: FIXME
#define _flag_log_sockets_telnet_outgoing
#include <net.h> #include <net.h>
//#include <status.h>
#include <services.h> #include <services.h>
#include <text.h> //#include <text.h>
//#include <uniform.h>
// this outgoing "telnet" socket thing implements both '/set mudlink'
// for users as MUD chatrooms such as @nemesis. would be cool if it
// actually was capable of handling telnet protocol, but the mud in
// question isn't, either.
//
// for a tighter integration between psyced and MUD it would also be
// cool to either have a native PSYC side channel, or to embed crypto-
// graphically signed PSYC packets (using a shared secret hash) into
// this stream.
// message queueing and automatic reconnect mgmt // message queueing and automatic reconnect mgmt
inherit NET_PATH "circuit"; inherit NET_PATH "circuit";
//inherit NET_PATH "place/public"; virtual inherit NET_PATH "output";
static string connectstring;
static object owner;
send(all) {
// if this doesn't work, then maybe you just forgot
// to /set charset in your test user
iconv(all, SYSTEM_CHARSET, "ASCII//TRANSLIT"); // should be configurable
#ifdef _flag_log_sockets_telnet_outgoing #ifdef _flag_log_sockets_telnet_outgoing
emit(all, source) { log_file("RAW_TN_OUT", "%O > %O\n", ME, all);
log_file("RAW_TN_OUT", "%d %O\t-> %s", time(), ME, all);
return ::emit(all);
}
#endif #endif
//if (function_exists("emit")) return emit(all);
return emit(all);
}
parse(all) { parse(all) {
next_input_to(#'parse); next_input_to(#'parse);
#ifdef _flag_log_sockets_telnet_outgoing #ifdef _flag_log_sockets_telnet_outgoing
log_file("RAW_TN_OUT", "%d %O\t<- %s", time(), ME, all); log_file("RAW_TN_OUT", "%O < %O\n", ME, all);
#endif #endif
// assumes multicaster.. fix later iconv(all, "ASCII//TRANSLIT", SYSTEM_CHARSET);
castmsg(ME, "_notice_telnet_verbatim", "[_text_verbatim]", if (owner) sendmsg(owner,
"_notice_telnet_verbatim", "[_text_verbatim]",
([ "_text_verbatim": all ]));
else if (function_exists("castmsg")) castmsg(ME,
"_notice_telnet_verbatim", "[_text_verbatim]",
([ "_text_verbatim": all ])); ([ "_text_verbatim": all ]));
} }
link(ho, po) { link(ho, po) {
sTextPath(0, 0, "tn"); //sTextPath(0, 0, "tn");
return ::circuit(ho, po || TELNET_SERVICE); return ::circuit(ho, po || TELNET_SERVICE);
} }
config(host, port, justdoit) {
connectstring = replace(justdoit, " ", "\n") + "\n";
owner = previous_object();
link(host, port);
}
logon(failure) { logon(failure) {
int rc = ::logon(failure); int rc = ::logon(failure);
unless (rc) return 0; unless (rc) return 0;
next_input_to(#'parse); next_input_to(#'parse);
parse("[connected]"); // hack to maintain logon ascii graphics intact parse("[connected]"); // hack to maintain logon ascii graphics intact
// could have queued this instead:
if (connectstring) call_out(#'send, 1, connectstring);
call_out(#'runQ, 3); // deliver the queue of messages in circuit.c call_out(#'runQ, 3); // deliver the queue of messages in circuit.c
return rc; return rc;
} }
@ -78,7 +108,7 @@ msg(source, mc, data, mapping vars, showingLog, target) {
if (abbrev("_message_public", mc)) { if (abbrev("_message_public", mc)) {
// FIXME: should we handle the disconnect instead? // FIXME: should we handle the disconnect instead?
if (data == "quit") return 1; if (data == "quit") return 1;
return emit(data + "\n"); return send(data + "\n");
} }
#endif #endif
} }
@ -99,7 +129,7 @@ render(string mc, string data, mapping vars, mixed source) {
output = psyctext( template, vars, data, source); output = psyctext( template, vars, data, source);
if (!output || output=="") return D2(D("tn/out: empty output\n")); if (!output || output=="") return D2(D("tn/out: empty output\n"));
if (template == "") output += "\n"; if (template == "") output += "\n";
emit(output); send(output);
} }
#endif #endif

View File

@ -143,6 +143,27 @@ input(a, dest) {
#endif #endif
} }
#define MUDLINK //FIXME
#ifdef MUDLINK
object mudlink;
mudlink(config) {
string connectstring, host; int port;
// should have mud nicknames instead, so that charsets, prompts
// and login procedures can be automated..
if (sscanf(config, "%s %d %s", host, port, connectstring)) {
// FIXME L8R:
//unless (objectp(mudlink)) mudlink = named_clone(NET_PATH "tn/outgoing", MYNICK);
unless (objectp(mudlink)) mudlink = clone_object(NET_PATH "tn/outgoing");
if (objectp(mudlink)) mudlink -> config(host, port, connectstring);
return 1;
}
// could produce a dedicated syntax warning here.. default is okay
return 0;
}
#endif
parsecmd(command, dest) { parsecmd(command, dest) {
array(string) args; array(string) args;
string a; string a;
@ -1393,6 +1414,14 @@ cmd(a, args, dest, command) {
w("_echo_save", "[_amount_lines] lines of log saved.", w("_echo_save", "[_amount_lines] lines of log saved.",
(["_amount_lines": t])); (["_amount_lines": t]));
break; break;
#ifdef MUDLINK
case "mud":
unless (objectp(mudlink) && interactive(mudlink)) mudlink(v("mudlink"));
// nicer UI using simulated query with $mud TBD.. FIXME
// also, this send() is not doing the translit!?!!
if (objectp(mudlink)) mudlink -> send(ARGS(1) +"\n");
break;
#endif // MUDLINK
#endif /* USER_PROGRAM */ #endif /* USER_PROGRAM */
default: default:
#ifdef USER_PROGRAM #ifdef USER_PROGRAM
@ -2664,6 +2693,7 @@ checkVar(key, value) {
string a, b; string a, b;
array(string) t; array(string) t;
P3(("%O checkVar(%O, %O)\n", ME, key, value))
// aliases for variable names // aliases for variable names
switch(key) { switch(key) {
case "befehlszeichen": case "befehlszeichen":
@ -2969,6 +2999,12 @@ checkVar(key, value) {
// case "popstarfave": // case "popstarfave":
// case "musicfave": // case "musicfave":
break; // always valid break; // always valid
#ifdef MUDLINK
case "mudlink":
P0(("mudlink %O\n", value))
if (value && !mudlink(value)) value = 0;
break;
#endif
case "encoding": case "encoding":
key = "charset"; // fall thru key = "charset"; // fall thru
case "charset": case "charset":