Method for chatting a number of historical records

zhaozj2021-02-16  161

Method for chatting a number of historical records

Sometimes, client history has increased continuous increases, which will cause Flash operation and slowness, which can be improved by limiting the number of historical records. Find the ReceiveMessage method in the client's CHAT component code, replace with the following code

1: fcchatclass.prototype.receiveMessage =

Function (MESG) {

2 :

//this.history_txt.htmlText = MESG; this line is the original implementation code

3: this.history.push (mesg);

4:

IF (this.history.length> 30) this.history.shift ();

5: this.history_txt.htmltext = this.history.join ("");

6: this.history_txt.scroll = this.history_txt.maxscroll;

7:}

Among them, the restriction record number can be adjusted himself, and it is set to 30. Define a History array in the fcchatclass.prototype.init method to save local chat record information

1: this.history =

New array ();

There is also a place to pay attention to the time when emptying history, you should also empty the local chat record:

1: this.history.splice (0);

转载请注明原文地址:https://www.9cbs.com/read-7728.html

New Post(0)