code.html

Warning: This file has been marked up for HTML

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="Author" content="Novell">
   <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
   <title>Novell Chat - Snapin Description</title>
</head>
<body>

<center><font size=+4><font face="Arial,Helvetica"><font color="#990000">Novell
</font></font><font color="#000000">Chat</font></font>
<br><font face="Arial,Helvetica"><font color="#000000"><font size=+2>for</font></font></font>
<br><font face="Arial,Helvetica"><font color="#666666"><font size=+3>ConsoleOne</font></font></font>
<p><font size=+2>Code Explanation</font></center>

<p><b>NOTE:</b>&nbsp; If you do not already have a basic understanding
of the concepts involved in writing snapins for ConsoleOne, I would suggest
that you first read through the <a href="http://developer.novell.com/ndk/doc/nco/index.htm">ConsoleOne
Developer's Guide</a> that is available on Novell's web site.&nbsp; This
provides a good overview of snapins and how they should be written.&nbsp;
Our discussion here will assume that you already have this background.
<p><b><font size=+1>Chatting Overview</font></b>
<p>The idea behind Chatting involves two fundamental concepts:&nbsp; a
client and a server.&nbsp; A client sends messages to a server that then
relays those messages to all of its clients.&nbsp; In our case, a user
who wants to chat (a client) can connects to a chat room (a server).&nbsp;
That chat room then acts as the relay point for all messages sent by the
users present in the room.&nbsp; Most chat services on the internet provide
a single chat server to which all users can connect.&nbsp; However, this
snapin takes a slightly different approach.
<p><b><font size=+1>ConsoleOne Chatting</font></b>
<p>To avoid needing a server that is a separate process running at some
central location, we have combined the client and the server into a single
program.&nbsp; Each person using the Chat snapin has the ability to act
as both the client and the server.&nbsp; When a chat room object is created
in NDS, the owner of the room becomes the room's server.&nbsp; All users
who connect to that room, are actually connecting to the user who created
it.&nbsp; But this leaves us with a problem.&nbsp; What happens when the
creator of a chat room shuts down ConsoleOne and logs off?&nbsp; Do we
just disconnect all of the users and end the chat session?&nbsp; No, we
just change the person whose action as server.&nbsp; When the creator of
a chat room logs off, the most recent member to enter the room is assigned
to be the new server.&nbsp; A message is sent to all of the clients telling
them the address of the new server.&nbsp; Each one reconnects to new server,
and the chatting continues.&nbsp; All of this happens behind the scenes
and without the users ever knowing.&nbsp; When the last user exits the
room, the room becomes idle until a new user enters.&nbsp; This new user
then becomes the server and the pattern continues.
<p>Since each user has the ability to act as either client, server or both,
users also have the ability to chat user-to-user without a chat room.&nbsp;
In this case, the connecting user that requests the chat session is the
client, and the user being connected to is the server.&nbsp; All users
automatically start a chat server when the snapin initializes so others
users can have a means of requesting them to chat.
<p><b><font size=+1>The Snapins</font></b>
<p>Now that we've discussed the basic concepts behind chatting, we'll now
explain a little about how this application plugs into ConsoleOne, and
the ways in which it utilizes NDS.&nbsp; As we begin to look at some of
the code for this snapin, you may also find it useful to open the <a href="api/index.html">API
reference guide</a>.&nbsp; This guide will give you a basic and quick overview
of the various classes and methods that are used by this snapin.
<p>Chat is actually made up of seven different types of snapins.&nbsp;
The following is a list of those snapins and the classes where their implementations
can be found.&nbsp; It is through these snapins that chat is initialized
and the user can interface with the snapin.
<br>&nbsp;
<center><table BORDER WIDTH="55%" >
<caption><b><font size=+1>Snapins Used by Chat</font></b></caption>

<tr>
<td>PageSnapin</td>

<td>(<a href="../src/com/novell/Chat/ChatRoomPageSnapin.java">ChatRoomPageSnapin.java</a>)</td>
</tr>

<tr>
<td>PopupMenuSnapin</td>

<td>(<a href="../src/com/novell/Chat/ChatPopupMenuSnapin.java">ChatPopupMenuSnapin.java</a>,
<a href="../src/com/novell/Chat/ChatRoomSnapins.java">ChatRoomSnapins.java</a>)</td>
</tr>

<tr>
<td>MenuSnapin</td>

<td>(<a href="../src/com/novell/Chat/ChatRoomSnapins.java">ChatRoomSnapins.java</a>,
<a href="../src/com/novell/Chat/DisableChatMenuSnapin.java">DisableChatMenuSnapin.java</a>)&nbsp;</td>
</tr>

<tr>
<td>ServiceSnapin</td>

<td>(<a href="../src/com/novell/Chat/ChatServiceSnapin.java">ChatServiceSnapin.java</a>)</td>
</tr>

<tr>
<td>ToolbarSnapin</td>

<td>(<a href="../src/com/novell/Chat/ChatRoomSnapins.java">ChatRoomSnapins.java</a>)</td>
</tr>

<tr>
<td>StatusBarSnapin</td>

<td>(<a href="../src/com/novell/Chat/ChatStatusBarSnapin.java">ChatStatusBarSnapin.java</a>)</td>
</tr>

<tr>
<td>AbstractToolBarMenuSnapin</td>

<td>(<a href="../src/com/novell/Chat/OnLineUserSnapin.java">OnLineUserSnapin.java</a>)</td>
</tr>
</table></center>

<p>Since each of these snapins need to be registered with ConsoleOne, a
single class has been provided to do handle all of the registrations (<a href="../src/com/novell/Chat/reg/ChatRegistration.java">ChatRegistration.java</a>).&nbsp;
Registering all of the snapins from the same class helps to speed up the
initialization of ConsoleOne.&nbsp; If you're mainly interested in seeing
how snapins are written, the above files should prove quite useful.&nbsp;
Only the code necessary to perform the snapin has been included in each
class, so you don't need to worry about being bogged down with code that
you're really not interested in seeing.
<p><b><font size=+1>Accessing NDS and Extending the Schema</font></b>
<p>A new class and six attributes are added to the NDS schema the first
time Chat is run with ConsoleOne.&nbsp; Two of those attributes are added
to the <i>User</i> object class:
<ul>
<li>
<i>ChatUserPort</i> (Syntax:&nbsp; Integer):&nbsp; Holds the port number
at which this user's server is listening for connections.&nbsp; In order
to chat with another user, you must first know the IP address and port
number of his chat server.&nbsp; The IP address is stored by the NetWare
server in his <i>Network Address </i>attribute and Chat stores his port
number in this attribute as soon as the server is created at startup.&nbsp;
It's by this attribute that the <i>On-Line Chat Users </i>dialog knows
if a user is on-line or not.&nbsp; This attribute is only present if the
user is on-line.</li>

<li>
<i>ChatPreferredUsers</i> (Syntax:&nbsp; Case Ignore String):&nbsp; Holds
the list of the users that have been placed in the <i>On-Line Chat Users</i>
dialog.&nbsp; By storing them here, the user doesn't have to reenter them
each time he starts ConsoleOne.</li>
</ul>
The other four new attributes are added to a new class.&nbsp; This new
class is named <i>Chat Room.</i>
<ul>
<li>
<i>ChatRoomIPAddress</i> (Syntax:&nbsp; Case Ignore String):&nbsp; Holds
the current IP address of the Chat Room.&nbsp; This value is changed when
the server is transferred from one user to the next.</li>

<li>
<i>ChatPort</i> (Syntax:&nbsp; Integer):&nbsp; Holds the current port number
of the Chat Room.&nbsp; This value is also changed when the server is transferred
from one user to the next.</li>

<li>
<i>ChatRoomOwner</i> (Syntax:&nbsp; Distinguished Name):&nbsp; This is
who created the Chat Room.&nbsp; Only the owner has the right to delete
a Chat Room or forcefully disconnect users.</li>

<li>
<i>ChatRoomUserList</i> (Syntax:&nbsp; Case Ignore String):&nbsp; The chat
room maintains a list of its current occupants.&nbsp; As a user enters
the room, his name is added to the list, and when he leaves, it is removed.</li>
</ul>
All of the methods for creating these new attributes can be found in the
class <a href="../src/com/novell/Chat/Chat.java">Chat.java</a>.&nbsp; This
class also contains the methods used to modify attribute values, change
trustee assignments, and locate objects from within NDS.&nbsp; Many of
these methods have been written in such a way as to simplify this process
and to be reusable.&nbsp; Unfortunately, this class also contains all of
the Chat management routines, so you might have to search around a little
bit in order to find these methods.
<center>
<p>&lt;<a href="using.html">Previous</a>&nbsp;&nbsp;&nbsp; <a href="index.html">Contents</a>&nbsp;&nbsp;
<a href="end.html">Next</a>></center>

</body>
</html>