Class ChatService

    • Constructor Detail

      • ChatService

        public ChatService()
    • Method Detail

      • start

        public IFuture<java.lang.Void> start()
        Called on startup.
      • shutdown

        public IFuture<java.lang.Void> shutdown()
        Called on shutdown.
      • getSubname

        protected java.lang.String getSubname()
        Get the "semi-qualified" sub name for settings.
      • message

        public IFuture<java.lang.Void> message​(java.lang.String nick,
                                               java.lang.String text,
                                               boolean privatemessage)
        Post a message
        Specified by:
        message in interface IChatService
        Parameters:
        text - The text message.
        nick - The sender's nick name.
      • status

        public IFuture<java.lang.Void> status​(java.lang.String nick,
                                              java.lang.String status,
                                              byte[] image)
        Post a status change.
        Specified by:
        status in interface IChatService
        Parameters:
        status - The new status.
        nick - The (possibly changed) nick name.
        image - The new image or null for no change.
      • sendFile

        public ITerminableIntermediateFuture<java.lang.Long> sendFile​(java.lang.String nick,
                                                                      java.lang.String filename,
                                                                      long size,
                                                                      java.lang.String id,
                                                                      IInputConnection con)
        Send a file.
        Specified by:
        sendFile in interface IChatService
        Parameters:
        nick - The sender's nick name.
        filename - The filename.
        size - The size of the file.
        id - An optional id to identify the transfer (e.g. for resume after error).
        con - The connection.
        Returns:
        The returned future publishes updates about the total number of bytes received. Exception messages of the returned future correspond to file transfer states (aborted vs. error vs. rejected).
      • startUpload

        public ITerminableFuture<IOutputConnection> startUpload​(java.lang.String nick,
                                                                java.lang.String filename,
                                                                long size,
                                                                java.lang.String id)
        Send a file. Alternative method signature.
        Specified by:
        startUpload in interface IChatService
        Parameters:
        nick - The sender's nick name.
        filename - The filename.
        size - The size of the file.
        id - An optional id to identify the transfer (e.g. for resume after error).
        Returns:
        When the upload is accepted, the output connection for sending the file is returned.
      • message

        public IIntermediateFuture<IChatService> message​(java.lang.String text,
                                                         IComponentIdentifier[] receivers,
                                                         boolean self)
        Post a message. Searches for available chat services and posts the message to all.
        Specified by:
        message in interface IChatGuiService
        Parameters:
        text - The text message.
        receivers - The receivers the message should be sent to.
        self - Flag if message should also be sent to service itself.
        Returns:
        The remote services, to which the message was successfully posted.
      • acceptFile

        public IFuture<java.lang.Void> acceptFile​(java.lang.String id,
                                                  java.lang.String filepath)
        Accept a waiting file transfer.
        Specified by:
        acceptFile in interface IChatGuiService
        Parameters:
        id - The transfer id.
        filepath - The location of the file (possibly changed by user).
      • rejectFile

        public IFuture<java.lang.Void> rejectFile​(java.lang.String id)
        Reject a waiting file transfer.
        Specified by:
        rejectFile in interface IChatGuiService
        Parameters:
        id - The transfer id.
      • cancelTransfer

        public IFuture<java.lang.Void> cancelTransfer​(java.lang.String id)
        Cancel an ongoing file transfer.
        Specified by:
        cancelTransfer in interface IChatGuiService
        Parameters:
        id - The transfer id.
      • sendFile

        public IFuture<java.lang.Void> sendFile​(java.lang.String filepath,
                                                IComponentIdentifier cid)
        Send a local file to the target component.
        Specified by:
        sendFile in interface IChatGuiService
        Parameters:
        filepath - The file path, local to the chat component.
        cid - The id of a remote chat component.
      • sendFile

        public IFuture<java.lang.Void> sendFile​(java.lang.String fname,
                                                byte[] data,
                                                IComponentIdentifier cid)
        Send a file to the target component via bytes.
        Specified by:
        sendFile in interface IChatGuiService
        Parameters:
        filepath - The file path, local to the chat component.
        cid - The id of a remote chat component.
      • publishEvent

        protected boolean publishEvent​(java.lang.String type,
                                       java.lang.String nick,
                                       IComponentIdentifier cid,
                                       java.lang.Object value)
        Post an event to registered subscribers.
        Parameters:
        type - The event type.
        nick - The nick name.
        cid - The component ID.
        value - The event value.
      • publishEvent

        protected boolean publishEvent​(java.lang.String type,
                                       java.lang.String nick,
                                       IComponentIdentifier cid,
                                       java.lang.Object value,
                                       boolean privatemessage,
                                       byte[] image)
        Post an event to registered subscribers.
        Parameters:
        type - The event type.
        nick - The nick name.
        cid - The component ID.
        value - The event value.