|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.zion.jbuddy.bots.BotClient
public class BotClient
Used by the bot engine to communicate with external networks.
A client can be specified in the Bot Definition File, or can be created
manually and added to a BotEngine
by calling
addClient
.
Constructor Summary | |
---|---|
BotClient(String protocol,
String name)
Creates a bot client. |
Method Summary | |
---|---|
void |
addBuddy(String name,
String displayName,
String group)
Adds a user to the client's buddy list. |
void |
addDeny(String name)
Adds a user to the client's deny list. |
void |
addPermit(String name)
Adds a user to the client's permit list. |
void |
connect()
Connects this client to an external network. |
void |
disconnect()
Disconnects this client from the external network. |
boolean |
equals(BotClient client)
Returns true if this client is equal to the specified client. |
boolean |
equals(Object object)
|
long |
getConnectTimeout()
Returns this client's connect timeout value, in milliseconds. |
Object |
getCustomProperty(String name)
Returns a custom property value. |
String |
getDescription()
Returns this client's description. |
String |
getDisplayName()
Returns this client's display name. |
BotEngine |
getEngine()
Returns the engine this client is associated with. |
Class |
getGatewayClass()
Returns this client's BotGateway class. |
String |
getHost()
Returns this client's host address. |
String |
getID()
Returns this client's identifier. |
IClient |
getJBuddyClient()
Returns the JBuddy SDK client being used. |
String |
getName()
Returns this client's unique name. |
String |
getPassword()
Returns this client's password. |
String |
getPermitMode()
Returns the client's permit mode. |
int |
getPort()
Returns this client's port. |
Properties |
getProperties()
Returns system properties that pertain to this client. |
String |
getProtocol()
Returns this client's protocol. |
BotStatistics |
getStatistics()
Returns this client's statistics. |
String |
getStatus()
Returns this client's status. |
String |
getStatusMessage()
Returns this client's status message. |
BotUser |
getUser(String name)
Returns the user session with the specified name. |
int |
hashCode()
|
boolean |
isConnected()
Returns whether this client is connected to an external network. |
boolean |
isConnecting()
Returns whether this client is in the process of connecting. |
boolean |
isPasswordEncrypted()
Returns whether the password is encrypted. |
void |
removeBuddy(String name)
Removes a user from the client's buddy list. |
void |
removeBuddy(String name,
String group)
Removes a user from the client's buddy list. |
void |
removeDeny(String name)
Removes a user from the client's deny list. |
void |
removePermit(String name)
Removes a user from the client's permit list. |
void |
sendFile(String userName,
BotFile file)
Sends a file to this user. |
void |
sendMessage(String userName,
BotMessage message)
Sends a message to a user. |
void |
setConnectTimeout(long connectTimeout)
Sets this client's connect timeout value, in milliseconds. |
Object |
setCustomProperty(String name,
Object value)
Sets a custom property value. |
void |
setDescription(String description)
Sets this client's description. |
void |
setDisplayName(String displayName)
Sets this client's display name. |
void |
setGatewayClass(Class gatewayClass)
Sets this client's BotGateway class. |
void |
setHost(String host)
Sets this client's host address. |
void |
setID(String id)
Sets this client's identifier, which can be used to reference this client. |
void |
setPassword(String password)
Sets this client's password. |
void |
setPasswordEncrypted(boolean passwordEncrypted)
Sets whether the password is encrypted. |
void |
setPermitMode(String permitMode)
Sets this client's permit mode. |
void |
setPort(int port)
Sets this client's port. |
void |
setStatus(String status,
String message)
Sets this client's status. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BotClient(String protocol, String name)
protocol
- the client's protocolname
- the client's unique nameMethod Detail |
---|
public BotEngine getEngine()
public String getProtocol()
public String getName()
public String getID()
public void setID(String id)
If not specified, the default value is name#protocol
. For
example, if a client's name is somebot
and its protocol is
AIM
, its default identifier is somebot#AIM
.
Client identifiers are used with routes
to reference
sender clients.
public long getConnectTimeout()
public void setConnectTimeout(long connectTimeout)
If a client's gateway takes longer than its specified timeout to connect
successfully, the connection attempt is canceled, and the gateway is
disconnected. If a timeout is not specified
(connectTimeout <= 0
), the gateway is allowed to take
any amount of time to complete.
The default value is 0
.
public String getDescription()
public void setDescription(String description)
This is an informational value, and is not used by the bot engine.
public String getDisplayName()
public void setDisplayName(String displayName)
This is normally visible to other users in messages or their buddy lists.
public Class getGatewayClass()
BotGateway
class.
public void setGatewayClass(Class gatewayClass)
BotGateway
class. The value must be the
class of a BotGateway
implementation.
If not specified, gateway support is provided internally by the
JBuddy SDK
. A custom gateway implementation should be
provided if necessary features are not already provided by the default
gateway (such as custom protocols, message types, or status types).
public String getHost()
public void setHost(String host)
This is the address of the server the client should connect to.
public int getPort()
public void setPort(int port)
This is the port number of the server the client should connect to.
public String getPassword()
public void setPassword(String password)
If passwordEncrypted
is true
, this value
must be the encrypted password string, obtained from the
EncryptPassword
utility included with the framework.
public boolean isPasswordEncrypted()
public void setPasswordEncrypted(boolean passwordEncrypted)
If true
, the password
value must be the
encrypted password string, obtained from the
EncryptPassword
utility included with the framework.
public Properties getProperties()
These properties are loaded into the Java system properties when this client gateway is in the process of connecting to its host. After connecting, the previous values of any system properties that were modified are restored.
System.setProperty(java.lang.String, java.lang.String)
public BotStatistics getStatistics()
public BotUser getUser(String name)
If the session already exists, it is returned. Otherwise, a new user session is created and returned.
This method must be called each time user input is to be processed. User session references should not be kept for longer than necessary, as the bot engine manages and removes sessions automatically, and references may become stale after some time.
public Object getCustomProperty(String name)
name
- the property's namepublic Object setCustomProperty(String name, Object value)
Custom properties can be attached to this client instance by an application using the bot framework, for convenience. They are not used by the engine itself.
name
- the property's namevalue
- the property's value (if null
, the property is
removed)
null
public boolean isConnecting()
public boolean isConnected()
public void connect() throws Exception
When connecting, a BotGateway
is instantiated for this client,
according to its gateway class
. The gateway
uses this client's properties and information (such as the protocol,
name, password, host, and port values) to set up a connection.
Once the client has connected successfully,
isConnected
will return true, and a
connected
event will be
fired. Otherwise, if the connection attempt fails for some reason, a
couldNotConnect
event will be fired.
Exception
BotClientConnectionListener
public void disconnect()
public IClient getJBuddyClient()
JBuddy SDK
client being used.
This call is equivalent to:
null
(if this client is not
connected, or the JBuddy SDK
is not being used)public void sendMessage(String userName, BotMessage message) throws Exception
The message is sent using the associated gateway
. A
sendMessage
event is also fired.
userName
- the name of the user to send tomessage
- the message
Exception
- if this client is not currently connectedpublic void sendFile(String userName, BotFile file) throws Exception
The file is sent using the associated gateway
. A
sendFile
event is also fired.
userName
- the name of the user to send tofile
- the file
Exception
- if this client is not currently connectedpublic String getStatus()
public String getStatusMessage()
public void setStatus(String status, String message) throws Exception
The status is set using the associated gateway
. A
setStatus
event is also fired.
status
- the statusmessage
- the status message
Exception
- if this client is not currently connectedpublic void addBuddy(String name, String displayName, String group) throws Exception
The buddy is added using the associated gateway
. A
addBuddy
event is also fired.
name
- the user's namedisplayName
- the user's display namegroup
- the group to add the user to
Exception
- if this client is not currently connectedpublic void removeBuddy(String name) throws Exception
The buddy is removed using the associated gateway
. A
removeBuddy
event is also fired.
name
- the user's name
Exception
- if this client is not currently connectedpublic void removeBuddy(String name, String group) throws Exception
The buddy is removed using the associated gateway
. A
removeBuddy
event is also fired.
name
- the user's namegroup
- the group to remove the user from; if a group is not
specified, the user is removed from all groups
Exception
- if this client is not currently connectedpublic String getPermitMode()
public void setPermitMode(String permitMode) throws Exception
The permit mode is set using the associated gateway
.
A setPermitMode
event is also
fired.
permitMode
- the permitMode
Exception
- if this client is not currently connectedpublic void addDeny(String name) throws Exception
The user is added using the associated gateway
. A
addDeny
event is also fired.
name
- the user's name
Exception
- if this client is not currently connectedpublic void removeDeny(String name) throws Exception
The user is removed using the associated gateway
. A
removeDeny
event is also fired.
name
- the user's name
Exception
- if this client is not currently connectedpublic void addPermit(String name) throws Exception
The user is added using the associated gateway
. A
addPermit
event is also fired.
name
- the user's name
Exception
- if this client is not currently connectedpublic void removePermit(String name) throws Exception
The user is removed using the associated gateway
. A
removePermit
event is also fired.
name
- the user's name
Exception
- if this client is not currently connectedpublic boolean equals(BotClient client)
public boolean equals(Object object)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |