Contents Index Topic Contents | ||
Previous Topic: Microsoft Chat Protocol 2.0 Next Topic: Microsoft Chat Protocol Control 2.0 Visual Basic Reference (Beta1 Release) |
Microsoft Chat Protocol Control 2.0 Visual Basic Overview (Beta1 Release)
The Microsoft® Chat Protocol Control 2.0 is an ActiveX control that allows the user to participate in a chat, or conversation, between two or more users connected to a chat server.
The Chat Protocol control allows the user to communicate both text and data, including arrays, Booleans, errors, currencies, and dates.
Stand-alone Microsoft Visual Basic® or Microsoft Visual C++® applications containing the Chat Protocol control or HTML pages that utilize the Chat Protocol control are referred to as chat clients. These chat clients communicate with a chat server through either the IRC (Internet Relay Chat) or IRCX (Extended Internet Relay Chat) protocols. The Chat Protocol control abstracts the IRC/IRCX protocols by the heavy use of objects and properties, thus insulating the developer from unnecessary knowledge of these protocols.
Because the Microsoft Chat Protocol Control 2.0 does not implement a user interface, developers are free to design and implement their own.
Using the Chat Protocol Control
The Chat Protocol Control
The Chat Protocol control is an ActiveX control that can be hosted by Microsoft Visual Basic or Microsoft Visual C++ applications. Web authors can also insert the Chat Protocol control into an HTML file with the <OBJECT> tag, and use Microsoft Visual Basic Scripting Edition (VBScript) to manipulate the control's properties, methods, and events. Web pages can be designed to query the user list, query the room lists, monitor the chat for specific events such as language type, notify when friends are online, and assign them specific privileges in a chat room.
Dependencies
The Chat Protocol control requires the presence of the Mschatpr.ocx on the user's computer. These files can be obtained by installing the Internet Client SDK. To implement Web pages that use the Chat Protocol control, the Web server must have access to a chat server. If the Chat Protocol control is implemented as a stand-alone client application, the computer running this application must have access to a chat server. The Chat Protocol control enables the connection from the user's computer to a chat channel, or chat room, on the chat server.
Licensing and Distribution
The Chat Protocol control is an ActiveX control that can be hosted by any ActiveX control container. This control is available for installation and redistribution on all computers with validly licensed copies of Microsoft operating system products (for example, Windows NT®, Windows® 95, and so on). For further information on licensing issues, refer to the License.txt file distributed with the Internet Client SDK.
Using the Chat Protocol Control
To use the Chat Protocol control, you can either directly log on to the chat server, or connect to the server prior to logging on.
You can connect to the server first to determine what security packages are available on the server. The following method is used to do this.
object.Connect ServerName
The following method is used to log on to a chat server.
object.Login ServerName, Nickname [, UserName] [, RealName] [, Password] [, SecurityPackages]
After logging on, you can add a Channel object to the Channels collection with the Add method. The Channels collection object is a standard Visual Basic collection object that uses the standard Add and Remove methods and the Item and Count properties.
Add method:
value=object.Add[(Index] [, Key)]
After the Channel object is created, you can join a channel with the JoinChannel or CreateChannel method. The CreateChannel method can be used only on an IRCX server.
JoinChannel method:
object.JoinChannel [ChannelName] [, ChannelKeyword]
CreateChannel method:
object.CreateChannel [ChannelName] [, ChannelKeyword] [, ChannelModes] [, MaxMemberCount]
Example
The following example adds Channel objects to the Channels collection with the Add method, and then joins the "Questions" Channel with the JoinChannel method:
Dim chan1, chan2 As Channel Set chan1 = MsChatPr1.Channels.Add(1, "Questions") Set chan2 = MsChatPr1.Channels.Add(2, "Answers") MsChatPr1.Channels(1).JoinChannel "Questions"All the channel methods and properties are available after the channel has been joined. For example, the SendMessage method sends text or data to the channel or a selective set of channel members.
object.SendMessage MessageType, Message [, RecipientNicknames] [, DataMessageTag]
Example
The following example sends a regular string to the channel.
MsChatPr1.Channels(1).SendMessage msgtNormal, "How are you?"For incoming messages, the OnMessage event is fired. You can use this event to update the user interface of the chat client.
object_OnMessage(Channel, SenderNickname, MessageType, Message, RecipientNicknames, DataMessageTag)
To leave the channel, the LeaveChannel method closes the current channel.
object.LeaveChannel
The Remove method removes a Channel object from the Channels collection.
object.Remove Index
Querying the Server for Information
Information regarding the server, a channel, a user, or a member can be obtained asynchronously or synchronously.
The Chat Protocol control supports sophisticated querying by the use of the ChatItems object. These queries relate to the server, a channel, a user, or a member. Generally, the information provided by the server is exposed to you through a ChatItems object.
The following example shows how to construct a ChatItems object to query the server for all users whose nicknames start with the letter 'a'.
Dim UserQueryItems As ChatItems Set UserQueryItems = New ChatItems UserQueryItems.AssociatedType = "Query" UserQueryItems.Item("Nickname") = "a" UserQueryItems.Item("NicknameOp") = "StartsWith" MsChatPr1.ListUsers UserQueryItems Set UserQueryItems = NothingNote: Because VBScript does not have a New operator, you need to use the control's NewChatItems property to create a new ChatItems object. Therefore, in VBScript, the first two lines of the preceding example would be:
Dim UserQueryItems Set UserQueryItems = MsChatPr1.NewChatItemsInformation can also be queried synchronously using the object properties. However, the control will be blocked until the server returns the required information. If the server has not returned the required information within a customizable period, the control throws a time-out error and unblocks. If the server sends the information later, the information will be exposed to the user through an event. You can alter this time-out period through the PropertyAccessTimeOut property.
The OBJECT Tag for HTML Pages
The following example uses the OBJECT tag to implement the Chat Protocol control.
<OBJECT ID=MsChatPr1 STANDBY="Downloading the Microsoft Chat Protocol Control" CODETYPE="application/x-oleobject" CLASSID="CLSID:039397C0-46DF-11D0-99CB-00C04FD64497" CODEBASE="MsChatPr.Cab"> </OBJECT>
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.