|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--javax.servlet.GenericServlet
|
+--javax.servlet.http.HttpServlet
|
+--com.chatessentials.GlassBot.GlassBot
GlassBot(R) Base Class
Description: This is the base class for a bot. You must derive your bots from this class and override public methods with your own methods. Each GlassBot can be executed through main() method or invoked in the GlassRoom server. In earlier method you must define your own main method and in second one you must copy the class files into "classes" folder of GlassRoom server and define the bot in the GlassRoom control panel.
Copyright: Copyright (c) 2003
Company: Chat Essentials co.
| Field Summary | |
static java.lang.String |
RET_PRIVATE_VOICE_ACC
|
static java.lang.String |
RET_PRIVATE_VOICE_REJ
|
boolean |
startedByMain
Indicates that bot is started by main() method. |
| Constructor Summary | |
GlassBot()
Default constructor of a bot. |
|
| Method Summary | |
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
doGet() method of Servlet called by servlet engine if you use this class as a servlet. |
void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
doPost() method of Servlet called by servlet engine if you use this class as a servlet. |
boolean |
getDebugMode()
Gets the state of debug mode. |
java.lang.String |
getNick()
Use this method to get nickname of bot. |
java.util.Properties |
getProperties()
Use this method to get the Properties object of bot. |
void |
init(javax.servlet.ServletConfig config)
This method is initialization method of super class ( Servlet). |
void |
initBot(java.net.InetAddress serverAddress,
java.lang.String botNick,
java.lang.String password,
java.lang.String defaultRoom,
java.lang.String propertiesFileName,
int directPort,
int servletPort,
int voicePort)
This method is called by GlassRoom to initialize the bot. |
void |
initFailed(char err)
This method is invoked by GlassRoom to indicate that bot is not initiated successfully. |
void |
initiated()
This method is invoked by GlassRoom to indicate that bot is initiated successfully. |
boolean |
isStarted()
Call this method to ensure that bot is started. |
void |
killerException()
Called by GlassRoom chat client when a killer exception such as disconnection is occured. |
static void |
main(GlassBot glassBot,
java.lang.String[] args)
Helper main() method to start the bot from command line. |
void |
onAlive()
Called by GlassRoom chat client when server replies to "alive" command |
void |
onBan(com.chatessentials.GlassRoom.UserMinor banned,
com.chatessentials.GlassRoom.UserMinor banner)
Called by GlassRoom chat client when a user bans other user. |
void |
onChatWatchPairs(java.lang.String[][] chatWatchPairsEng)
Called by GlassRoom chat client when a list of chatwatch pairs arrives to the bot. |
void |
onCloseRoom(java.lang.String roomName)
Called by GlassRoom chat client when a room is closed |
void |
onError(int errorNumber)
Called by GlassRoom chat client when an error is occured |
void |
onFileReceive(com.chatessentials.GlassRoom.UserMinor user,
java.lang.String sFileURL,
boolean sentInPublic)
Called by GlassRoom chat client when a public file is sent to the bot. |
void |
onInit()
Called by GlassRoom chat client when first phase of initialization of user get finished in chat server. |
void |
onInitBot(java.net.InetAddress serverAddress,
java.lang.String botNick,
java.lang.String password,
java.lang.String defaultRoom,
java.lang.String propertiesFileName,
int directPort,
int servletPort,
int voicePort)
Called by GlassRoom to indicate that bot is started. |
void |
onInitializationFinished()
Called by GlassRoom chat client when second phase of initialization get finished in chat server. |
void |
onJoin(com.chatessentials.GlassRoom.UserMinor user,
com.chatessentials.GlassRoom.ChannelMinor room,
java.lang.String secondName,
int imageNo)
Called by GlassRoom chat client when a user enters a room. |
void |
onListRooms()
Called by GlassRoom chat client when a list of rooms arrives to the bot. |
void |
onListUsersInRoom(java.lang.String listedRoom)
Called by GlassRoom chat client when a list of users of a room arrives to the bot. |
void |
onLogin(com.chatessentials.GlassRoom.UserMinor user,
java.lang.String secondName,
int imageNo)
Called by GlassRoom chat client when a user login to system. |
void |
onLogout(java.lang.String nick)
Called by GlassRoom chat client when a user leaves the system. |
void |
onModifyRoom(java.lang.String oldRoomName,
com.chatessentials.GlassRoom.ChannelMinor newRoom)
Called by GlassRoom chat client when a room name is changed |
void |
onNewRoom(com.chatessentials.GlassRoom.ChannelMinor room)
Called by GlassRoom chat client when a new room is created. |
void |
onNickChange(java.lang.String oldNick,
java.lang.String newNick)
Called by GlassRoom chat client when a user changes his nickname |
void |
onPart(com.chatessentials.GlassRoom.UserMinor user,
com.chatessentials.GlassRoom.ChannelMinor room)
Called by GlassRoom chat client when a user leaves a room. |
void |
onPrivateMessage(com.chatessentials.GlassRoom.UserMinor sender,
java.lang.String message,
java.net.URL url)
Called by GlassRoom chat client when a private message arrives to this bot. |
void |
onPrivateVoiceAcc(com.chatessentials.GlassRoom.UserMinor sender,
java.lang.String address,
int port)
Called by GlassRoom chat client when a user accepts your private voice chat request. |
void |
onPrivateVoiceReject(com.chatessentials.GlassRoom.UserMinor sender)
Called by GlassRoom chat client when a user rejects your private voice chat request. |
void |
onPrivateVoiceReq(com.chatessentials.GlassRoom.UserMinor sender,
java.lang.String address,
int port)
Called by GlassRoom chat client when a private voice chat session request arrives to this bot. |
void |
onProfChange(com.chatessentials.GlassRoom.UserMinor user,
java.lang.String secondName,
int imageNo)
Called by GlassRoom chat client when a user changes his profile |
void |
onProfile(com.chatessentials.GlassRoom.UserMinor user,
com.chatessentials.GlassRoom.UserInfo ui)
Called by GlassRoom chat client when a user changes his profile. |
void |
onPublicMessage(com.chatessentials.GlassRoom.UserMinor sender,
java.lang.String message,
java.net.URL url,
boolean isBroadCast)
Called by GlassRoom chat client when a public message arrives to this bot. |
void |
onSetNick(java.lang.String nick)
Called by GlassRoom chat client when nickname of bot is set. |
void |
onSpeakOff(com.chatessentials.GlassRoom.UserMinor user)
Called by GlassRoom chat client when the speaker finishes his speaking. |
void |
onSpeakOn(com.chatessentials.GlassRoom.UserMinor user,
long timeToSpeak)
Called by GlassRoom chat client when a user starts to speak in the current voice room of bot. |
void |
onSpeakTimeOut()
Called by GlassRoom chat client when the bot's time-to-speak get finished. |
void |
onStartBot()
Called by GlassRoom to indicate that bot is started. |
void |
onStartTypingMessage(com.chatessentials.GlassRoom.UserMinor sender)
Called by GlassRoom chat client when a user starts typing in a private chat window. |
void |
onStopBot()
Called by GlassRoom to indicate that bot is stopped. |
void |
onStopTypingMessage(com.chatessentials.GlassRoom.UserMinor sender)
Called by GlassRoom chat client when a user stops typing in a private chat window. |
void |
onTalkStart()
Called by GlassRoom chat client when the bot starts to record voice. |
void |
onVoiceJoin(com.chatessentials.GlassRoom.UserMinor user,
com.chatessentials.GlassRoom.ChannelMinor room)
Called by GlassRoom chat client when a user do voice-join to a room. |
void |
onVoiceOff(com.chatessentials.GlassRoom.UserMinor user)
Called by GlassRoom chat client when a user turns his voice off. |
void |
onVoiceOn(com.chatessentials.GlassRoom.UserMinor user)
Called by GlassRoom chat client when a user turns his voice on. |
void |
onVoicePart(com.chatessentials.GlassRoom.UserMinor user,
com.chatessentials.GlassRoom.ChannelMinor room)
Called by GlassRoom chat client when a user do voice-part from a room. |
void |
onYouBan(com.chatessentials.GlassRoom.UserMinor banner)
Called by GlassRoom chat client when the bot is banned. |
void |
onYouJoin(com.chatessentials.GlassRoom.ChannelMinor room)
Called by GlassRoom chat client when the bot enters a room. |
void |
onYouPart(com.chatessentials.GlassRoom.ChannelMinor room)
Called by GlassRoom chat client when the bot leaves a room. |
void |
onYourProfile()
Called by GlassRoom chat client when the chat server accepts your profile change |
void |
onYouVoiceJoin(com.chatessentials.GlassRoom.ChannelMinor room)
Called by GlassRoom chat client when the bot do voice-join (listen) to a room |
void |
onYouVoicePart(com.chatessentials.GlassRoom.ChannelMinor room)
Called by GlassRoom chat client when the bot do voice-part from a room. |
void |
run()
|
void |
sendPrivateMessage(java.lang.String mess,
java.lang.String nick)
Use this method to send private messages to a user. |
void |
sendPrivateMessage(java.lang.String mess,
java.lang.String nick,
java.lang.String url)
Use this method to send public messages with URL. |
void |
sendPublicMessage(java.lang.String mess)
Use this method to send public messages to the current room. |
void |
sendPublicMessage(java.lang.String mess,
java.lang.String url)
Use this method to send public messages with URL. |
void |
sendRaw(java.lang.String str)
Use this method to send raw messages to server. |
void |
setDebugMode(boolean b)
You may set 'debugMode' variable to switch the bot to debug mode. |
void |
start()
Called internally to start bot thread. |
void |
startBot()
This method is called by GlassRoom to start the bot. |
void |
stop()
Called internally to stop bot thread. |
void |
stopBot()
This method is called by GlassRoom to stop the bot. |
| Methods inherited from class javax.servlet.http.HttpServlet |
service |
| Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, log |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String RET_PRIVATE_VOICE_ACC
public static final java.lang.String RET_PRIVATE_VOICE_REJ
public boolean startedByMain
| Constructor Detail |
public GlassBot()
initBot(java.net.InetAddress, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int, int, int) then startBot() methods.
| Method Detail |
public void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
doGet in class javax.servlet.http.HttpServletrequest - response -
javax.servlet.ServletException
java.io.IOExceptionjavax.servlet.Servlet#doGet
public void doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
doPost in class javax.servlet.http.HttpServletrequest - response -
javax.servlet.ServletException
java.io.IOExceptionjavax.servlet.Servlet#doPostpublic boolean getDebugMode()
public java.lang.String getNick()
public java.util.Properties getProperties()
Properties object of bot.
Properties object.initBot()
public void init(javax.servlet.ServletConfig config)
throws javax.servlet.ServletException
Servlet). If you
plan to use the bot as a servlet. You can initialize and start it in this method. If
you start the bot by main() method or you embedd the bot directly in GlassRoom chat server
don't override this method.
init in interface javax.servlet.Servletinit in class javax.servlet.GenericServletjavax.servlet.ServletException
public final void initBot(java.net.InetAddress serverAddress,
java.lang.String botNick,
java.lang.String password,
java.lang.String defaultRoom,
java.lang.String propertiesFileName,
int directPort,
int servletPort,
int voicePort)
throws java.lang.Exception
startBot() to start the bot after initialization.
serverAddress - IP address of server.botNick - Nickname of bot.password - Password of bot (if required).You can define a user with the nickName
of the bot and define a password for it in GlassRoom database. In this case you can
assign special rights to bot through control panel.defaultRoom - Default room of bot. Bot will automatically enter in this room.propertiesFileName - Path of properties file in standard Java properties format.
each property is composed from a pair of a key and a value. Each line of properties
file contains a pair in form of key=value. '!' and '#' are used for comment lines.
This properties file will load in a Properties object that can be retrieved
through getProperties() method. For exaqmple if you want to get a value named as
foo, you can use the below code:
String foo = adsFileName = getProperties().getProperty("foo");
directPort - Direct connection port number. Default is 7100.
java.lang.Exceptionpublic void initFailed(char err)
err - The error code returned by chat server.public void initiated()
public boolean isStarted()
public void killerException()
public static void main(GlassBot glassBot,
java.lang.String[] args)
glassBot - GlassBot derived objectargs - Same as "args" sent to main method of derived object.public void onAlive()
public void onBan(com.chatessentials.GlassRoom.UserMinor banned,
com.chatessentials.GlassRoom.UserMinor banner)
banned - User who is bannedbanner - User who banpublic void onChatWatchPairs(java.lang.String[][] chatWatchPairsEng)
chatWatchPairsEng - Array of pairs of words to be found and replaced.public void onCloseRoom(java.lang.String roomName)
roomName - name of roompublic void onError(int errorNumber)
errorNumber - number of error
public void onFileReceive(com.chatessentials.GlassRoom.UserMinor user,
java.lang.String sFileURL,
boolean sentInPublic)
user - Sender of filesFileURL - URL to get the file fromsentInPublic - Is file sent in public or privatepublic void onInit()
public void onInitBot(java.net.InetAddress serverAddress,
java.lang.String botNick,
java.lang.String password,
java.lang.String defaultRoom,
java.lang.String propertiesFileName,
int directPort,
int servletPort,
int voicePort)
throws java.lang.Exception
java.lang.Exceptionpublic void onInitializationFinished()
public void onJoin(com.chatessentials.GlassRoom.UserMinor user,
com.chatessentials.GlassRoom.ChannelMinor room,
java.lang.String secondName,
int imageNo)
user - User who entered to roomroom - RoomsecondName - Second name of userimageNo - Icon number of userpublic void onListRooms()
public void onListUsersInRoom(java.lang.String listedRoom)
listedRoom - Room which is listed. Room name is started with "#" and a "#" room name
stands for list of users who have no room.
public void onLogin(com.chatessentials.GlassRoom.UserMinor user,
java.lang.String secondName,
int imageNo)
user - User who login to systemsecondName - Second name of userimageNo - Icon number of userpublic void onLogout(java.lang.String nick)
nick - Nickname of user
public void onModifyRoom(java.lang.String oldRoomName,
com.chatessentials.GlassRoom.ChannelMinor newRoom)
oldRoomName - Old name of roomnewRoom - New name of roompublic void onNewRoom(com.chatessentials.GlassRoom.ChannelMinor room)
room - Room object
public void onNickChange(java.lang.String oldNick,
java.lang.String newNick)
oldNick - Old nicknamenewNick - new nickname
public void onPart(com.chatessentials.GlassRoom.UserMinor user,
com.chatessentials.GlassRoom.ChannelMinor room)
user - User who leaves the roomroom - Room
public void onPrivateMessage(com.chatessentials.GlassRoom.UserMinor sender,
java.lang.String message,
java.net.URL url)
sender - Sender of messagemessage - Message bodyurl - URL included in message. null if thers is no URL.
public void onPrivateVoiceAcc(com.chatessentials.GlassRoom.UserMinor sender,
java.lang.String address,
int port)
sender - Requester useraddress - IP address of requesterport - Port number of requesterpublic void onPrivateVoiceReject(com.chatessentials.GlassRoom.UserMinor sender)
sender - User that rejected the private voice chat session.
public void onPrivateVoiceReq(com.chatessentials.GlassRoom.UserMinor sender,
java.lang.String address,
int port)
sendRaw( PRIVATE_VOICE_ACC + ' ' + sender );
or
sendRaw( PRIVATE_VOICE_REJ + ' ' + sender );
to reject the request.
If you accept private voice chat session then you can open your private chat window by opening the
below URL :
String url = "http://" + communicator.host + ":"
+ communicator.SERVLET_PORT + communicator.UPLOAD_SERVLET_PATH_NAME + '?'
+ "com=V&"
+ "nic=" + URLEncoder.encode(ni) + '&'
+ "add=" + URLEncoder.encode(address) + '&'
+ "port=" + URLEncoder.encode(port) + '&'
+ "doc=" + URLEncoder.encode(applet.getCodeBase().toString());
sender - Requester useraddress - IP address of requesterport - Port number of requester
public void onProfChange(com.chatessentials.GlassRoom.UserMinor user,
java.lang.String secondName,
int imageNo)
user - User objectsecondName - Second name of userimageNo - Icon number of user
public void onProfile(com.chatessentials.GlassRoom.UserMinor user,
com.chatessentials.GlassRoom.UserInfo ui)
user - User objectui - User information
public void onPublicMessage(com.chatessentials.GlassRoom.UserMinor sender,
java.lang.String message,
java.net.URL url,
boolean isBroadCast)
sender - Sender of messagemessage - Message bodyurl - URL included in message. null if thers is no URL.isBroadCast - Is it a broadcast message ?public void onSetNick(java.lang.String nick)
nick - Nicknamepublic void onSpeakOff(com.chatessentials.GlassRoom.UserMinor user)
user - User object
public void onSpeakOn(com.chatessentials.GlassRoom.UserMinor user,
long timeToSpeak)
user - User objecttimeToSpeak - Time to speak of user. The talk button will be disabled
this time.public void onSpeakTimeOut()
public void onStartBot()
throws java.lang.Exception
java.lang.Exceptionpublic void onStartTypingMessage(com.chatessentials.GlassRoom.UserMinor sender)
sender - User who send this messagepublic void onStopBot()
public void onStopTypingMessage(com.chatessentials.GlassRoom.UserMinor sender)
sender - User who send this messagepublic void onTalkStart()
public void onVoiceJoin(com.chatessentials.GlassRoom.UserMinor user,
com.chatessentials.GlassRoom.ChannelMinor room)
user - User objectroom - Room objectpublic void onVoiceOff(com.chatessentials.GlassRoom.UserMinor user)
user - User objectpublic void onVoiceOn(com.chatessentials.GlassRoom.UserMinor user)
user - User object
public void onVoicePart(com.chatessentials.GlassRoom.UserMinor user,
com.chatessentials.GlassRoom.ChannelMinor room)
user - User objectroom - Room objectpublic void onYouBan(com.chatessentials.GlassRoom.UserMinor banner)
banner - User who banpublic void onYouJoin(com.chatessentials.GlassRoom.ChannelMinor room)
room - Roompublic void onYouPart(com.chatessentials.GlassRoom.ChannelMinor room)
room - Roompublic void onYourProfile()
public void onYouVoiceJoin(com.chatessentials.GlassRoom.ChannelMinor room)
room - Roompublic void onYouVoicePart(com.chatessentials.GlassRoom.ChannelMinor room)
room - public final void run()
run in interface java.lang.Runnable
public void sendPrivateMessage(java.lang.String mess,
java.lang.String nick)
mess - Message to be sentnick - Nickname of target user
public void sendPrivateMessage(java.lang.String mess,
java.lang.String nick,
java.lang.String url)
mess - Message to be sentnick - Nickname of target userurl - URL address of the pagepublic void sendPublicMessage(java.lang.String mess)
mess - Message to be send.
public void sendPublicMessage(java.lang.String mess,
java.lang.String url)
mess - Message to be senturl - URL address of the pagepublic void sendRaw(java.lang.String str)
str - String to be send to server.public void setDebugMode(boolean b)
b - Turns on/off the debug mode.public void start()
startBot() method to start
bot. Don't call this method directly or override it.
public final void startBot()
throws BotException,
java.lang.Exception
initBot(java.net.InetAddress, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int, int, int) must be called to
initialize the bot before this method.
BotException
java.lang.Exceptionpublic void stop()
stopBot() method to stop
bot. Don't call this method directly or override it.
public final void stopBot()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||