Man Linux: Main Page and Category List

NAME

       YsendClientMessage - Client message sending

SYNTAX

       #include <Y2/Y.h>
       #include <Y2/Ylib.h>

       int YSendClientMessage(
               YConnection *con,
               Boolean notify_self,
               int format,
               int type,
               const char *message,
               int length
       )

ARGUMENTS

       connection
              Specifies  the connection to the Y server, obtained by a call to
              YOpenConnection.

       notify_self
              specifies to notify this Y client of the  message  as  well,  in
              which  case  this  Y  client will receive a YClientMessage event
              containing the sent message.

       format Specifies  the  format  of  the   message,   can   be   one   of
              YClientMessageFormat*.

       type   Specifies  the  type  of  message,  this  is  often  a  Y client
              determined value.  However there are  some  commonly  used  type
              values defined by one of YClientMessageType* that you can use.

       message
              Specifies  the  message  content,  it  can  not  be  longer than
              YClientMessageMessageMax bytes. This value can also be NULL,  in
              which case length should be 0.

       length Specifies  the length of the message in bytes, this value can be
              0 to YClientMessageMessageMax bytes.

DESCRIPTION

       The YSendClientMessage function sends the specified message  to  all  Y
       clients and the Y server (including this Y client if notify_self is set
       to True).

       A YClientMessage event will be generated.

RETURN VALUE

       The YSendClientMessage function returns 0 on success or -1 on  failure.

EXAMPLE

       #include <stdio.h>
       #include <string.h>
       #include <Y2/Y.h>
       #include <Y2/Ylib.h>

       int main(int argc, char *argv[])
       {
               const char *message;
               YConnection *con = YOpenConnection(
                       "/usr/sbin/starty",
                       "127.0.0.1:9433"
               );
               if(con == NULL)
                       return(1);

               /* Our message. */
               message = "Hello world!";

               /* Send client message. */
               if(YSendClientMessage(
                       con,
                       False,
                       YClientMessageFormatString,
                       YClientMessageTypeComment,
                       message,
                       strlen(message)
               ))
                       printf("Error.\n");
               else
                       printf("Success!\n");

               YCloseConnection(con, False);

               return(0);
       }

SEE ALSO

       YEventClientMessage(3)