public class DefaultClient extends Object implements Client.WithManagement
Client
.Client.Builder, Client.Commands, Client.WithManagement
Constructor and Description |
---|
DefaultClient()
Creates a new default client.
|
Modifier and Type | Method and Description |
---|---|
void |
addChannel(String... channels)
Adds channels to this client.
|
void |
addKeyProtectedChannel(Pair<String,String>... channelsAndKeys)
Adds key-protected channels to this client.
|
void |
addKeyProtectedChannel(@NonNull String channel,
@NonNull String key)
Adds a key-protected channel to this client.
|
void |
beginMessageSendingImmediate(@NonNull Consumer<String> consumer)
Starts the sending of queued 'immediately' messages.
|
@NonNull Client.Commands |
commands()
Provides access to
Command s. |
void |
connect()
Begin connecting to the server.
|
@NonNull ActorTracker |
getActorTracker()
Gets the actor tracker.
|
@NonNull AuthManager |
getAuthManager()
Gets the authentication manager.
|
@NonNull InetSocketAddress |
getBindAddress()
Gets the bind address
|
CapabilityManager.WithManagement |
getCapabilityManager()
Gets the capability manager.
|
@NonNull Optional<Channel> |
getChannel(@NonNull String name)
Gets a snapshot of known information about a named channel, if the
channel is being tracked by the client.
|
@NonNull Set<Channel> |
getChannels()
Gets the channels in which the client is currently present.
|
@NonNull Set<Channel> |
getChannels(@NonNull Collection<String> channels)
Gets the channels on the given collection in which the client is
currently present.
|
@NonNull DefaultMessageMap |
getDefaultMessageMap()
Gets the message manager for default messages to reply with
when certain messages are being sent.
|
@NonNull EventManager |
getEventManager()
Gets the client's event manager.
|
@NonNull Listener<Exception> |
getExceptionListener()
Gets the exception listener.
|
@NonNull Listener<String> |
getInputListener()
Gets the currently set input listener.
|
@NonNull Set<String> |
getIntendedChannels()
Gets the channels the client intends to join.
|
@NonNull String |
getIntendedNick()
Gets the nickname the client intends to possess.
|
@NonNull ISupportManager |
getISupportManager()
Gets the manager of ISUPPORT info.
|
@NonNull Cutter |
getMessageCutter()
Gets the current message cutter for multi-line messages.
|
@NonNull Function<Client.WithManagement,? extends MessageSendingQueue> |
getMessageSendingQueueSupplier()
Gets the message sending queue supplier.
|
@NonNull MessageTagManager |
getMessageTagManager()
Gets the message tag manager.
|
@NonNull String |
getName()
Gets the client name.
|
@NonNull NetworkHandler |
getNetworkHandler()
Gets the network handler.
|
@NonNull String |
getNick()
Gets the current nickname the client has.
|
@NonNull Listener<String> |
getOutputListener()
Gets the currently set output listener.
|
@NonNull Optional<HostWithPort> |
getProxyAddress()
Gets the proxy address
|
@NonNull Optional<ProxyType> |
getProxyType()
Gets if the client is configured to use a proxy.
|
@NonNull String |
getRequestedNick()
Gets the nickname the client has last requested.
|
@Nullable Path |
getSecureKey()
Gets the TLS key.
|
@Nullable Path |
getSecureKeyCertChain()
Gets the TLS key certificate chain.
|
@Nullable String |
getSecureKeyPassword()
Gets the TLS key password.
|
@Nullable TrustManagerFactory |
getSecureTrustManagerFactory()
Gets the trust manager factory.
|
@NonNull HostWithPort |
getServerAddress()
Gets the server address
|
ServerInfo.WithManagement |
getServerInfo()
Gets information about the server to which the client is currently
connected.
|
@NonNull Optional<StsMachine> |
getStsMachine()
Gets the STS machine instance, if one is in use.
|
@NonNull Optional<User> |
getUser()
Gets the User that the client is represented by.
|
@NonNull Optional<ModeStatusList<UserMode>> |
getUserModes()
Gets the user's modes.
|
void |
initialize(@NonNull String name,
@NonNull NetworkHandler networkHandler,
@NonNull HostWithPort serverAddress,
@Nullable String serverPassword,
@Nullable InetSocketAddress bindAddress,
@Nullable HostWithPort proxyAddress,
@Nullable ProxyType proxyType,
@NonNull String nick,
@NonNull String userString,
@NonNull String realName,
@NonNull ActorTracker actorTracker,
@NonNull AuthManager authManager,
CapabilityManager.WithManagement capabilityManager,
@NonNull EventManager eventManager,
@NonNull List<EventListenerSupplier> listenerSuppliers,
@NonNull MessageTagManager messageTagManager,
@NonNull ISupportManager iSupportManager,
@Nullable DefaultMessageMap defaultMessageMap,
@NonNull Function<Client.WithManagement,? extends MessageSendingQueue> messageSendingQueue,
@NonNull Function<Client.WithManagement,? extends ServerInfo.WithManagement> serverInfo,
@Nullable Consumer<Exception> exceptionListener,
@Nullable Consumer<String> inputListener,
@Nullable Consumer<String> outputListener,
boolean secure,
@Nullable Path secureKeyCertChain,
@Nullable Path secureKey,
@Nullable String secureKeyPassword,
@Nullable TrustManagerFactory trustManagerFactory,
@Nullable StsStorageManager stsStorageManager,
@Nullable String webircHost,
@Nullable InetAddress webircIP,
@Nullable String webircPassword,
@Nullable String webircGateway)
Initialize with pre-connection information.
|
boolean |
isConnectionAlive()
Gets if the connection is alive.
|
boolean |
isSecureConnection()
Gets if the client is configured for a secure connection.
|
void |
knockChannel(@NonNull String channelName)
KNOCKs on a +i (but not +p) channel, requesting an INVITE.
|
void |
pauseMessageSending()
Pauses message sending, waiting for next successful connection.
|
void |
ping()
Sends a PING.
|
void |
processLine(@NonNull String line)
Queue up a line for processing.
|
void |
reconnect()
Triggers a reconnect, quitting with the default
DefaultMessageType.RECONNECT message. |
void |
reconnect(@Nullable String reason)
Triggers a reconnect, quitting with the given reason.
|
void |
removeChannel(@NonNull String channelName)
Removes a channel from the client, leaving as necessary.
|
void |
removeChannel(@NonNull String channelName,
@Nullable String reason)
Removes a channel from the client, leaving as necessary.
|
void |
sendCtcpMessage(@NonNull String target,
@NonNull String message)
Sends a CTCP message to a target user or channel.
|
void |
sendCtcpReply(@NonNull String target,
@NonNull String message)
Sends a CTCP reply to a target user or channel.
|
void |
sendMessage(@NonNull String target,
@NonNull String message)
Sends a message to a target user or channel.
|
void |
sendMultiLineMessage(@NonNull String target,
@NonNull String message,
@NonNull Cutter cutter)
Sends a potentially multi-line message to a target user or channel
using the defined
Cutter . |
void |
sendMultiLineNotice(@NonNull String target,
@NonNull String message,
@NonNull Cutter cutter)
Sends a potentially multi-line notice to a target user or channel
using the defined
Cutter . |
void |
sendNickChange(@NonNull String newNick)
Sends a nick change request.
|
void |
sendNotice(@NonNull String target,
@NonNull String message)
Sends a notice to a target user or channel.
|
void |
sendRawLine(@NonNull String message)
Sends a raw IRC message.
|
void |
sendRawLineAvoidingDuplication(@NonNull String message)
Sends a raw IRC message, unless the exact same message is already in
the queue of messages not yet sent.
|
void |
sendRawLineImmediately(@NonNull String message)
Sends a raw IRC message, disregarding message delays and all sanity.
|
void |
setCurrentNick(@NonNull String nick)
Sets the current nickname the client knows it has.
|
void |
setDefaultMessageMap(@NonNull DefaultMessageMap defaults)
Sets the message manager for default messages to reply with
when certain messages are being sent.
|
void |
setExceptionListener(@Nullable Consumer<Exception> listener)
Sets a listener for all thrown exceptions on this client.
|
void |
setInputListener(@Nullable Consumer<String> listener)
Sets a listener for all incoming messages from the server.
|
void |
setMessageCutter(@NonNull Cutter cutter)
Sets the default message cutter to use for multi-line messages.
|
void |
setMessageSendingQueueSupplier(@NonNull Function<Client.WithManagement,? extends MessageSendingQueue> supplier)
Sets the message sending queue supplier.
|
void |
setNetworkHandler(@NonNull NetworkHandler networkHandler)
Sets the network handler, for the next time a connection is made.
|
void |
setNick(@NonNull String nick)
Sets the nick the client wishes to use.
|
void |
setOutputListener(@Nullable Consumer<String> listener)
Sets a listener for all outgoing messages to the server.
|
void |
setServerAddress(@NonNull HostWithPort address)
Sets the server address.
|
void |
setUserModes(@NonNull ModeStatusList<UserMode> userModes)
Sets the client's user modes.
|
void |
shutdown()
Shuts down the client without a quit message.
|
void |
shutdown(@Nullable String reason)
Shuts down the client.
|
void |
startSending()
Starts sending queued messages.
|
@NonNull String |
toString() |
void |
updateUserModes(@NonNull ModeStatusList<UserMode> userModes)
Updates the client's user modes.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
builder, getClient, isUser, sendCtcpMessage, sendCtcpReply, sendMessage, sendMultiLineMessage, sendMultiLineMessage, sendMultiLineMessage, sendMultiLineNotice, sendMultiLineNotice, sendMultiLineNotice, sendNotice
public void initialize(@NonNull String name, @NonNull NetworkHandler networkHandler, @NonNull HostWithPort serverAddress, @Nullable String serverPassword, @Nullable InetSocketAddress bindAddress, @Nullable HostWithPort proxyAddress, @Nullable ProxyType proxyType, @NonNull String nick, @NonNull String userString, @NonNull String realName, @NonNull ActorTracker actorTracker, @NonNull AuthManager authManager, CapabilityManager.WithManagement capabilityManager, @NonNull EventManager eventManager, @NonNull List<EventListenerSupplier> listenerSuppliers, @NonNull MessageTagManager messageTagManager, @NonNull ISupportManager iSupportManager, @Nullable DefaultMessageMap defaultMessageMap, @NonNull Function<Client.WithManagement,? extends MessageSendingQueue> messageSendingQueue, @NonNull Function<Client.WithManagement,? extends ServerInfo.WithManagement> serverInfo, @Nullable Consumer<Exception> exceptionListener, @Nullable Consumer<String> inputListener, @Nullable Consumer<String> outputListener, boolean secure, @Nullable Path secureKeyCertChain, @Nullable Path secureKey, @Nullable String secureKeyPassword, @Nullable TrustManagerFactory trustManagerFactory, @Nullable StsStorageManager stsStorageManager, @Nullable String webircHost, @Nullable InetAddress webircIP, @Nullable String webircPassword, @Nullable String webircGateway)
Client.WithManagement
initialize
in interface Client.WithManagement
name
- namenetworkHandler
- networkHandlerserverAddress
- serverHostWithPortserverPassword
- serverPasswordbindAddress
- bindAddressproxyAddress
- proxyAddressproxyType
- proxyTypenick
- nickuserString
- userStringrealName
- realNameactorTracker
- actorTrackerauthManager
- authManagercapabilityManager
- capabilityManagereventManager
- eventManagerlistenerSuppliers
- listenerSuppliersmessageTagManager
- messageTagManageriSupportManager
- iSupportManagerdefaultMessageMap
- defaultMessageMapmessageSendingQueue
- messageSendingQueueserverInfo
- serverInfoexceptionListener
- exceptionListenerinputListener
- inputListeneroutputListener
- outputListenersecure
- securesecureKeyCertChain
- secureKeyCertChainsecureKey
- secureKeysecureKeyPassword
- secureKeyPasswordtrustManagerFactory
- trustManagerFactorystsStorageManager
- stsStorageManagerwebircHost
- webircHostwebircIP
- webircIPwebircPassword
- webircPasswordwebircGateway
- webircUserpublic void addChannel(String... channels)
Client
Joins the channels if already connected.
addChannel
in interface Client
channels
- channel(s) to addRequestedChannelJoinCompleteEvent
,
UnexpectedChannelLeaveEvent
public void addKeyProtectedChannel(@NonNull String channel, @NonNull String key)
Client
Joins the channels if already connected.
addKeyProtectedChannel
in interface Client
channel
- channel to addkey
- channel keypublic void addKeyProtectedChannel(Pair<String,String>... channelsAndKeys)
Client
Joins the channels if already connected.
addKeyProtectedChannel
in interface Client
channelsAndKeys
- pairs of channel, keypublic @NonNull AuthManager getAuthManager()
Client
getAuthManager
in interface Client
public @NonNull InetSocketAddress getBindAddress()
Client.WithManagement
getBindAddress
in interface Client.WithManagement
public CapabilityManager.WithManagement getCapabilityManager()
Client
getCapabilityManager
in interface Client
getCapabilityManager
in interface Client.WithManagement
public @NonNull Optional<Channel> getChannel(@NonNull String name)
Client
getChannel
in interface Client
name
- channel nameClient.getChannels()
public @NonNull Set<Channel> getChannels()
Client
getChannels
in interface Client
public @NonNull Set<Channel> getChannels(@NonNull Collection<String> channels)
Client
getChannels
in interface Client
channels
- collection of channel names to getpublic @NonNull DefaultMessageMap getDefaultMessageMap()
Client
getDefaultMessageMap
in interface Client
public @NonNull EventManager getEventManager()
Client
getEventManager
in interface Client
public @NonNull Listener<Exception> getExceptionListener()
Client
getExceptionListener
in interface Client
public @NonNull String getIntendedNick()
Client
Use Client.getNick()
for the current nick.
getIntendedNick
in interface Client
public @NonNull ISupportManager getISupportManager()
Client
getISupportManager
in interface Client
public @NonNull Optional<StsMachine> getStsMachine()
Client
getStsMachine
in interface Client
public @NonNull Cutter getMessageCutter()
Client
getMessageCutter
in interface Client
public @NonNull Function<Client.WithManagement,? extends MessageSendingQueue> getMessageSendingQueueSupplier()
Client
SingleDelaySender
with a delay of 1200.getMessageSendingQueueSupplier
in interface Client
public @NonNull MessageTagManager getMessageTagManager()
Client
getMessageTagManager
in interface Client
public @NonNull String getName()
Client
public @NonNull String getNick()
Client
public @NonNull NetworkHandler getNetworkHandler()
Client.WithManagement
getNetworkHandler
in interface Client.WithManagement
public ServerInfo.WithManagement getServerInfo()
Client
ClientNegotiationCompleteEvent
getServerInfo
in interface Client
getServerInfo
in interface Client.WithManagement
public @NonNull Optional<User> getUser()
Client
Optional.empty()
until the Client is in a Channel for which joining
has completed, meaning full user info is available.public @NonNull Optional<ModeStatusList<UserMode>> getUserModes()
Client
Optional.empty()
until the
Client has queried this information, which is requested after the
connection registration has completed.getUserModes
in interface Client
public void knockChannel(@NonNull String channelName)
Client
knockChannel
in interface Client
channelName
- the channel to send the KNOCK for.public void removeChannel(@NonNull String channelName)
Client
removeChannel
in interface Client
channelName
- channel to leavepublic void removeChannel(@NonNull String channelName, @Nullable String reason)
Client
removeChannel
in interface Client
channelName
- channel to leavereason
- part reasonpublic void sendCtcpMessage(@NonNull String target, @NonNull String message)
Client
Note: CTCP replies should not be sent this way. Catch the message
with the PrivateCtcpQueryEvent
and reply there or use
Client.sendCtcpReply(String, String)
sendCtcpMessage
in interface Client
target
- the destination of the messagemessage
- the message to sendpublic void sendCtcpReply(@NonNull String target, @NonNull String message)
Client
sendCtcpReply
in interface Client
target
- the destination of the messagemessage
- the message to sendpublic void sendMessage(@NonNull String target, @NonNull String message)
Client
sendMessage
in interface Client
target
- the destination of the messagemessage
- the message to sendpublic void sendMultiLineMessage(@NonNull String target, @NonNull String message, @NonNull Cutter cutter)
Client
Cutter
.
Note that bots may not react appropriately to a message split across multiple lines.
sendMultiLineMessage
in interface Client
target
- the destination of the messagemessage
- the message to sendcutter
- cutter to utilizepublic void sendMultiLineNotice(@NonNull String target, @NonNull String message, @NonNull Cutter cutter)
Client
Cutter
.
Note that bots may not react appropriately to a message split across multiple lines.
sendMultiLineNotice
in interface Client
target
- the destination of the messagemessage
- the message to sendcutter
- cutter to utilizepublic @Nullable Path getSecureKey()
Client.WithManagement
getSecureKey
in interface Client.WithManagement
public @Nullable Path getSecureKeyCertChain()
Client.WithManagement
getSecureKeyCertChain
in interface Client.WithManagement
public @Nullable String getSecureKeyPassword()
Client.WithManagement
getSecureKeyPassword
in interface Client.WithManagement
public @Nullable TrustManagerFactory getSecureTrustManagerFactory()
Client.WithManagement
getSecureTrustManagerFactory
in interface Client.WithManagement
public @NonNull HostWithPort getServerAddress()
Client.WithManagement
getServerAddress
in interface Client.WithManagement
public @NonNull Optional<ProxyType> getProxyType()
Client.WithManagement
getProxyType
in interface Client.WithManagement
true
if configured for proxypublic @NonNull Optional<HostWithPort> getProxyAddress()
Client.WithManagement
getProxyAddress
in interface Client.WithManagement
public void sendNotice(@NonNull String target, @NonNull String message)
Client
sendNotice
in interface Client
target
- the destination of the messagemessage
- the message to sendpublic void sendRawLine(@NonNull String message)
Client
sendRawLine
in interface Client
message
- message to sendpublic void sendRawLineAvoidingDuplication(@NonNull String message)
Client
sendRawLineAvoidingDuplication
in interface Client
message
- message to sendpublic void sendRawLineImmediately(@NonNull String message)
Client
sendRawLineImmediately
in interface Client
message
- message to send dangerously, you monsterpublic void setExceptionListener(@Nullable Consumer<Exception> listener)
Client
All exceptions are passed from a single, separate thread.
setExceptionListener
in interface Client
listener
- catcher of throwable objectspublic void setDefaultMessageMap(@NonNull DefaultMessageMap defaults)
Client
setDefaultMessageMap
in interface Client
defaults
- DefaultMessageMap to setpublic void setInputListener(@Nullable Consumer<String> listener)
Client
All messages are passed from a single, separate thread.
setInputListener
in interface Client
listener
- input listenerpublic void setMessageCutter(@NonNull Cutter cutter)
Client
setMessageCutter
in interface Client
cutter
- cutter to setpublic void setMessageSendingQueueSupplier(@NonNull Function<Client.WithManagement,? extends MessageSendingQueue> supplier)
Client
setMessageSendingQueueSupplier
in interface Client
supplier
- the supplierpublic void setNetworkHandler(@NonNull NetworkHandler networkHandler)
Client.WithManagement
setNetworkHandler
in interface Client.WithManagement
networkHandler
- new network handlerpublic void setNick(@NonNull String nick)
Client
public void setOutputListener(@Nullable Consumer<String> listener)
Client
All messages are passed from a single, separate thread.
setOutputListener
in interface Client
listener
- output listenerpublic void shutdown()
Client
public void shutdown(@Nullable String reason)
Client
public void processLine(@NonNull String line)
processLine
in interface Client.WithManagement
line
- line to be processedpublic @NonNull ActorTracker getActorTracker()
Client.WithManagement
getActorTracker
in interface Client.WithManagement
public boolean isConnectionAlive()
Client.WithManagement
isConnectionAlive
in interface Client.WithManagement
public @NonNull Listener<String> getInputListener()
Client.WithManagement
getInputListener
in interface Client.WithManagement
public @NonNull Set<String> getIntendedChannels()
Client.WithManagement
getIntendedChannels
in interface Client.WithManagement
public @NonNull Listener<String> getOutputListener()
Client.WithManagement
getOutputListener
in interface Client.WithManagement
public @NonNull String getRequestedNick()
Client.WithManagement
getRequestedNick
in interface Client.WithManagement
public void connect()
Client
public void beginMessageSendingImmediate(@NonNull Consumer<String> consumer)
Client.WithManagement
beginMessageSendingImmediate
in interface Client.WithManagement
consumer
- consumer with which to handle this queuepublic void pauseMessageSending()
Client.WithManagement
pauseMessageSending
in interface Client.WithManagement
public void ping()
Client.WithManagement
ping
in interface Client.WithManagement
public void sendNickChange(@NonNull String newNick)
Client.WithManagement
sendNickChange
in interface Client.WithManagement
newNick
- new nicknamepublic void setCurrentNick(@NonNull String nick)
Client.WithManagement
setCurrentNick
in interface Client.WithManagement
nick
- nicknamepublic void setServerAddress(@NonNull HostWithPort address)
Client.WithManagement
setServerAddress
in interface Client.WithManagement
address
- server addresspublic void setUserModes(@NonNull ModeStatusList<UserMode> userModes)
Client.WithManagement
setUserModes
in interface Client.WithManagement
userModes
- user modes to setpublic void startSending()
Client.WithManagement
startSending
in interface Client.WithManagement
public void updateUserModes(@NonNull ModeStatusList<UserMode> userModes)
Client.WithManagement
updateUserModes
in interface Client.WithManagement
userModes
- mode changespublic void reconnect()
Client
DefaultMessageType.RECONNECT
message.public void reconnect(@Nullable String reason)
Client
public boolean isSecureConnection()
Client.WithManagement
isSecureConnection
in interface Client.WithManagement
public @NonNull Client.Commands commands()
Client
Command
s.Copyright © 2013–2021 Kitteh. All rights reserved.