From 51d61320a63eadc16dc6c5efd9aa591a38e63ea8 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 3 Feb 1999 03:44:44 +0000 Subject: [PATCH] new GEXP command --- citadel/serv_chat.c | 35 +++++++++++++++++++++++++++++++++++ citadel/serv_chat.h | 1 + citadel/techdoc/session.txt | 31 ++++++++++++++++++++++++++++--- 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/citadel/serv_chat.c b/citadel/serv_chat.c index 0086aaa75..539bdc0ec 100644 --- a/citadel/serv_chat.c +++ b/citadel/serv_chat.c @@ -58,6 +58,7 @@ struct DLModule_Info *Dynamic_Module_Init(void) { CtdlRegisterProtoHook(cmd_chat, "CHAT", "Begin real-time chat"); CtdlRegisterProtoHook(cmd_pexp, "PEXP", "Poll for express messages"); + CtdlRegisterProtoHook(cmd_gexp, "GEXP", "Get express messages"); CtdlRegisterProtoHook(cmd_sexp, "SEXP", "Send an express message"); CtdlRegisterSessionHook(delete_express_messages, EVT_STOP); return &info; @@ -398,6 +399,40 @@ void cmd_pexp(char *argbuf) } +/* + * Get express messages (new method) + */ +void cmd_gexp(char *argbuf) { + struct ExpressMessage *ptr; + + if (CC->FirstExpressMessage == NULL) { + cprintf("%d No express messages waiting.\n", ERROR); + return; + } + + begin_critical_section(S_SESSION_TABLE); + ptr = CC->FirstExpressMessage; + CC->FirstExpressMessage = CC->FirstExpressMessage->next; + end_critical_section(S_SESSION_TABLE); + + cprintf("%d %d|%ld|%d|%s|%s\n", + LISTING_FOLLOWS, + ((ptr->next != NULL) ? 1 : 0), /* more msgs? */ + ptr->timestamp, /* time sent */ + ptr->flags, /* flags */ + ptr->sender, /* sender of msg */ + config.c_nodename); /* static for now */ + if (ptr->text != NULL) { + cprintf("%s", ptr->text); + if (ptr->text[strlen(ptr->text)-1] != '\n') cprintf("\n"); + phree(ptr->text); + } + cprintf("000\n"); + phree(ptr); +} + + + /* * This is the back end to the express message sending function. * Returns the number of users to which the message was sent. diff --git a/citadel/serv_chat.h b/citadel/serv_chat.h index a6b00c910..982a18411 100644 --- a/citadel/serv_chat.h +++ b/citadel/serv_chat.h @@ -8,3 +8,4 @@ void cmd_pexp (char *argbuf); /* arg unused */ char check_express (void); void cmd_sexp (char *argbuf); void delete_express_messages(void); +void cmd_gexp(char *); diff --git a/citadel/techdoc/session.txt b/citadel/techdoc/session.txt index f535a74c8..03c272f60 100644 --- a/citadel/techdoc/session.txt +++ b/citadel/techdoc/session.txt @@ -1278,7 +1278,7 @@ to other users currently in chat. This is one of two commands which implement "express messages" (also known as "paging"). An express message is a near-real-time message sent from one logged in user to another. When an express message is sent, it will be -displayed the next time the target user executes a PEXP command. +displayed the next time the target user executes a PEXP or GEXP command. The SEXP command accepts two arguments: the name of the user to send the message to, and the text of the message. If the message is successfully @@ -1299,9 +1299,12 @@ in using a client that does not check for express messages, the message will never be received. - PEXP (Print EXPress messages) + PEXP (Print EXPress messages) ***DEPRECATED*** - This command, called without any arguments, simply dumps out the contents + This command is deprecated; it will eventually disappear from the protocol and +its use is not recommended. Please use the GEXP command instead. + + Called without any arguments, PEXP simply dumps out the contents of any waiting express messages. It returns ERROR if there is a problem, otherwise it returns LISTING_FOLLOWS followed by all messages. @@ -1651,3 +1654,25 @@ parameters which must be passed to this command are the message number and the name of the desired section. If the message or section does not exist, an appropriate ERROR code will be returned; otherwise, if the open is successful, this command will succeed returning the same information as an OPEN command. + + + GEXP (Get EXPress messages) + + This is a more sophisticated way of retrieving express messages than the old +PEXP method. If there are no express messages waiting, PEXP returns ERROR; +otherwise, it returns LISTING_FOLLOWS and the following arguments: + + 0 - a boolean value telling the client whether there are any additional + express messages waiting following this one + 1 - a Unix-style timestamp + 2 - flags (see server.h for more info) + 3 - the name of the sender + 4 - the node this message originated on (for future support of PIP, ICQ, etc.) + + The text sent to the client will be the body of the express message. + + So how does the client know there are express messages waiting? It could +execute a random GEXP every now and then. Or, it can check the byte in +server return code messages, between the return code and the parameters. In +much the same way as FTP uses "-" to signify a continuation, Citadel uses +an "*" in this position to signify the presence of waiting express messages. -- 2.39.2