After I wrote the article "Implementing the private Message function in an ASP chat room," a lot of my friends wrote to ask me questions about other advanced functionality implementations. Indeed, such as room, user management and other advanced functions is a perfect chat room must have the function. The room function is more difficult to achieve in this area. So I would like to talk to you about this issue.
I still tend to use arrays to solve these two problems, which is not to say that you can't solve them with a database, but we have to consider the performance problem. Moreover, the array has several advantages, which is advantageous to the sorting, and helps to control the total length. Long standing in server memory (for performance improvement). Let me tell you a few questions about the room, and here's how to switch between the two system rooms. As for the method of building a house, I hope we can analogy. There are also questions about the online display of users, because we have to show both the users and the total users of each room, so there will be some interaction with the room, please note when speaking. For the convenience of everyone to use, I try to write these functions as subroutines or sub functions, we can directly apply.
It is important that we look at the definition in Gloable.asa first.
The following are the referenced contents:
<script language= "VBScript" runat= "Server" >
Sub Application_OnStart ()
Application ("groom_name") = "Carefree Tour" ' Save the name of the main chat room, all people go to the chat room first
Dim Pchat_value (50)
Application (Application ("Groom_name") & "_value") =pchat_value ' p stands for private g on behalf of globle to keep the free chat room content
Application (Application ("Groom_name") & "_number") =0 ' number of conversations used to save the chat room
Application ("Health Master" & "_value") =pchat_value
Application ("Health Master" & "_number") =0
Dim Pchater_value (150)
Application (Application ("Groom_name") & "Er_value") =pchater_value ' names of the chats used to keep the getaway chat room
Application (Application ("Groom_name") & "Er_number") =0 ' used to indicate the number of online chat rooms
Application ("Health Master" & "Er_value") =pchater_value
Application ("Health Master" & "Er_number") =0
Dim Proom_value (50)
Proom_value (0) = "Xiaoyao Tour" & "(" & "System" & ")" & "[" &application "(Application (" Groom_name ") &" Er_number ") &"] "&" Person "
Proom_value (1) = "Health Main" & "(" & "System" & ")" & "[" &application "(" Health Master "&" Er_number ") &"] "&" Person "
Application ("Groom_value") =proom_value ' to preserve the name of the room
Application ("Groom_number") =2
End Sub
Sub Session_OnStart ()
Session ("Sroom_name") =application ("Groom_name") ' Default room for each new user
Session ("schater_name") = "" "' s for the session to hold the speaker's name
Strprovider= "Driver={microsoft Access Driver (*.mdb)}; Dbq= "&server.mappath". /chat ") &" & "Db\chater_message.mdb;"
Set Cres=server.createobject ("ADODB. Connection ")
Set Res=server.createobject ("ADODB. Recordset ")
Cres.open strprovider
Res.activeconnection=cres
Set session ("res") =res ' instance of a recordset
End Sub
|
Total 3 page: previous 1 [2] [3] Next page