This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Under the Hood of the Chat Component
|
559
Changing MyChat: Turning Off the Chat History
Now that we have a custom MyChat component as embodied in mychat.asc,wecan
simplify it so that it, for example, doesn’t save the chat’s history. With this change,
users will not receive the transcript of the prior conversation when they first log on;
instead, they’ll receive only messages sent after they have logged on. The easiest way
to remove such functionality is to delete every reference to the
history array from the
server-side code, so it looks like this:
try {var dummy = MyChat;} catch (e) { // #ifndef MyChat
load("components/component.asc");
MyChat = function (name) {
this.init(name);
this.message_so = SharedObject.get(this.prefix + "message", false);
};
MyChat.prototype = new FCComponent("MyChat",MyChat);
MyChat.prototype.message_so = null;
// This is called when the application is about to stop.
MyChat.prototype.onAppStop = function ( ) {
};
// The first method called by a client component.
MyChat.prototype.connect = function (client) {
var cglobal = this.getClientGlobalStorage(client);
if (!cglobal.usercolor) {
cglobal.usercolor = "0x000000";
}
client.call(this.callPrefix + "setUsername", null, cglobal.username);
};
// The last method called by a client component.
MyChat.prototype.close = function (client) {
};
// Send a message to all others participating in the chat session.
MyChat.prototype.sendMessage = function (client, mesg) {
var cglobal = this.getClientGlobalStorage(client);
mesg = this.hiliteURLs(mesg);
var hexColor = "#" + cglobal.usercolor.substring(2, cglobal.usercolor.length)
mesg = "<font color=\"" + hexColor + "\"><b>" + cglobal.username + ": </b>" +
mesg + "</font><br>\n";
this.message_so.send("message", mesg);
};
// Highlight the urls in a message.
MyChat.prototype.hiliteURLs = function (msg) {
// Code removed, look at the original chat.asc.
return hilited;
};

Get Programming Flash Communication Server now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.