Teach you to build ASP voice chat room

Source: Internet
Author: User
Tags empty interface servervariables port number
Chat Room The first step: Download Voice chat room server-side program, we want to use the Bchat studio Bchat server.

1. Enter the http://bchat.yinsha.com/page;
2. The "Hot headline" On the right side of the page has the words "Bchat launches 10 users for free download", what we need is it;
3. Click on "bchat launched 10 users free download version" of the link, to the free version of the download page;
4. Download the "Windows version" in the download page (other versions I have not used, I will use the Windows version);
5. After downloading the file is Bchat.zip, unzip him to a directory (for later you use it in the ASP program of the website, this directory should be a directory of your website, such as C:\Inetpub\wwwroot\);
6. After the operation of the above, Bchat server was installed into the C:\Inetpub\wwwroot\Bchat\ directory;
7. Enter the C:\Inetpub\wwwroot\Bchat\ directory, you can see the directory has 7 files and 3 subdirectories;
8. Copy all the files in the GB subdirectory to the current directory (the current directory is the C:\Inetpub\wwwroot\Bchat\ directory), so that you can install a voice chat room with Simplified Chinese interface. (If you want to install the English interface, then copy the files in Chinese subdirectory to the current directory; If you want to install the traditional language interface, copy the files from the Big5 subdirectory to the current directory.) )

Step two: Create a database. (Although you can use a voice chat room without a database, we want a powerful "ASP" voice chat room, so use a database!) )

1. Run access to establish an empty database, the database name is Bchat.mdb, the database is stored in the C:\Inetpub\wwwroot\Bchat\ directory;
2. Select "CREATE table using designer";
3. Add a field. Field name bname, data type select text;
4. Add one more field. Field name Bport, data type select number;
5. Close this (designer window). After the point is closed, prompt you to "Save Changes", select "Y", then let you enter the name of the table, enter room, and OK. Then access prompts "No primary key defined", ignore him, and select "No N".
6. Now the room table is established, but there is no data in it, we hand him a few pieces of data.
7. Double-click the room table to add the data; bname to enter the "room" (this is the room name, you can write casually), bport there input 5100 (this is the Bchat server running the port number, you can also casually write. But this port number can not be used in the system of the port, if you are unfamiliar with the port, then write the 5100,5100 is generally idle;
8. Add another piece of data; bname fill "room second", Bport fill 5200;
9. Close Access.

Step three: Write an ASP program. (The program I have written, you copy the following code on the line, and then save the file as Index.asp, and save to the C:\Inetpub\wwwroot\Bchat\ directory.) )

<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<%option explicit%>
<%
'*************************************************************
' Program name: ASP Voice chat Room
' Program implementation: must rely on bchat Server, download address http://bchat.yinsha.com
' Program design: Madpolice
' Finish time: 2003-2-23 17:36:00
' Description: 1. Test pass on my Windows Advanced server,
' does not guarantee normal operation in other environments.
' 2. I do not require any copyright, but please keep my name, OK?
'**************************************************************
Dim Db,connstr,conn,rs,sql,serverip

db= "Bchat.mdb"
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &server.mappath (db)
' If your server is powered by an older version of Access, use the following connection method
' connstr= ' Driver={microsoft Access driver (*.mdb)};d bq= "&server.mappath (db)
Set conn=server.createobject ("ADODB. Connection ")
Conn. Open ConnStr
Set rs=server.createobject ("ADODB. RecordSet ")
Serverip=request.servervariables ("Local_addr")
Sql= "SELECT * from Room order by Bport"

Rs. Open sql,conn,1,1
If Rs. EOF Then
Rs. Close
Set rs=nothing
Conn. Close
Set conn=nothing
There's no record in the Response.Write database! "
Response.End
End If

If application ("Bchat_status") <> "Running" Then
Call Startbchat ()
Rs. MoveFirst
End If
%>
<title> Voice chat room </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<script language= "JavaScript" >
var wwwhost= "<%=request.servervariables (" SERVER_NAME ")%>";
function Go (pport) {
if (Validname (Document.form1.elements[0])) {
document[' Form1 '].action= ' http://' +wwwhost+ ': ' +pport+ '/';
Launchchat ();
document[' Form1 '].method= ' post ';
Document.form1.submit ();
}
}
function Validname (STR1)
{
var s,i,j;
if (Str1.value.length <1) {
Alert ("Please enter your name, you cannot be empty!") ");
Str1.focus ();
return false;
}
return true;
}
var Focusok=false;
if (navigator.appname = "Netscape") {
Focusok=true;
}
Vers = navigator.appversion;
if (navigator.appname = = "Microsoft Internet Explorer") {
pos = Vers.lastindexof ('. ');
Vers = Vers.substring (pos-1,vers.length);
}
Proper_version = parsefloat (vers);

if (proper_version>=5) {
Focusok=true;
}
function Launchchat () {
var chat = window.open ("", "chat", "Top=0,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no, scrollbars=yes,resizable=yes,width=790,height=530 ");
if (Focusok) {
Chat.focus ();
}
return true;
}
</script>
<body>
<form action=/method=post name=form1 target= "chat" align= "center" >
<p align=center> Please first name: <input type= "text" name= "USER" size= "" maxlength= "" ></p>
<center><div align=center>
<table border=1 width= "60%" >
<%do while not Rs. Eof%>
<tr height=20>
&LT;TD width= "70%" >



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.