new GEXP command
authorArt Cancro <ajc@citadel.org>
Wed, 3 Feb 1999 03:44:44 +0000 (03:44 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 3 Feb 1999 03:44:44 +0000 (03:44 +0000)
citadel/serv_chat.c
citadel/serv_chat.h
citadel/techdoc/session.txt

index 0086aaa754dcb9c43cc2c88050a2ddb71e64fd5d..539bdc0ec5e853e2c8be51744f59df50f9b03133 100644 (file)
@@ -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.
index a6b00c910bf4d922ad38e9c2654fee2d4d422f2d..982a184118008545dc4596d9ccca307c86efd5dc 100644 (file)
@@ -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 *);
index f535a74c81ae3240f1f2459cb3945e7eece5c004..03c272f608efbd2a20d158384bbbaba2d84bcc75 100644 (file)
@@ -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.