软件开发集成环境课程设计.docx
《软件开发集成环境课程设计.docx》由会员分享,可在线阅读,更多相关《软件开发集成环境课程设计.docx(27页珍藏版)》请在冰豆网上搜索。
软件开发集成环境课程设计
《软件开发集成环境》课程设计
题目:
小QQ聊天工具
系院:
专业:
年级:
组别:
成员:
完成日期:
指导教师:
:
没有良好的条件,有的是团结拼搏的决心;
没有尖端的技术,有的是进取务实的态度;
踏出这一步,成功进一步!
目的和意义*****************************************
项目背景*******************************************
设计要求*******************************************
项目说明*******************************************
需求分析**************************************************
性能分析**************************************************
可行性分析************************************************
主要数据*******************************************
程序运行的条件************************************
源代码************************************************
服务器编码***********************************************
执行编码**************************************************
执行结果与分析*******************************************
设计总结**************************************************
参考文献**************************************************
一:
目的和意义
21世纪是一个以网络核心的信息化时代,要实现信息化,增强人们之间的交流很大部分是依靠在QQ上聊,但前提是必须有完善的QQ聊天室,通过本课程设计使学生对QQ聊天室的功能和运行的具体过程有所了解,同时也对掌握的只是有了更深的运用,将所学知识用于实践之中,增强了学生的动手能力。
二:
项目背景
当今是一个以网络为核心的信息化时代,是一个蓬勃发展的时代,因此,仅仅依靠电话进行交流已经远远不能满足人们的需求。
小QQ聊天工具则应运而生,它的方便灵活为人们解决了这个难题。
为了体现我们所学的知识以及提高我们的操作实践能力,经过讨论后本小组决定设计一个简单的QQ聊天室。
三:
设计要求
1.根据要求对QQ聊天室进行需求分析,提交需求作品;
2.在需求分析的基础上进行系统设计;
3.便于客户端进行操作;
4.聊天室操作程序源代码易懂;
5.要求界面设计简洁、使用方便,能够完成基本的聊天室功能。
四:
项目说明
聊天室分为服务器端和客户端两部分,服务器端程序主要负责侦听客户端发来的消息,客户端需要登录到服务器端才可以实现正常的聊天功能。
1、服务器端的主要功能如下:
●在特定端口上进行侦听,等待客户端连接。
●用户可以配置服务器端的侦听接口,默认端口为1080。
●向已经连接到服务器端的用户发送系统消息。
●统计在线人数。
●当停止服务器时,断开所有的用户连接。
2、客户端的重要功能如下:
●连接到已经开启聊天服务的服务器端。
●用户可以配置要连接的服务器端的IP地址和端口号。
●用户可以配置连接后显示的用户名。
●当服务器端开启的话,用户可以随时登陆和注销。
●用户可以向所有人或某一个人发送消息。
(一)需求分析:
Ø注册:
服务器收到用户的注册请求,便开始接受客户传递的信息,诸如客户的昵称,姓名,籍贯,个人资料等,接受完毕后,便通过Jdbc-Odbc与后台数据库连接,然后向数据库添加记录,如果成功,便向客户返回其号码。
客户收到服务器返回的信息后,便打开主登陆窗口。
Ø登陆:
在客户端用户输入其号码和密码,然后建立与服务器的连接,告诉服务器我要登陆,开始通过Jdbc-Odbc读取数据库,然后与用户输入的信息比较如果成功便打开主窗口,然后客户向服务器请求读取好友名单,服务器收到该请求,开始读取数据库的表,得到好友的号码后再在icp表中读取好友资料,然后向客户端发送这些信息,客户收到后就在主创口显示好友。
,并且建立几个矢量,用、用以存储好友的昵称号码。
(二)性能分析:
本系统由于采用免费的oracle数据库软件,连接数最多不能超过200,所以并发访问数据库的人数不能超过200。
(三)可行性分析:
✧经济可行性:
本系统需要一个oracle数据库服务器,由于使用人数比较少,安装一个免费的oracle数据库完全可以应付需要。
✧操作可行性:
只要一台以上计算机连接在同一局域网内,本系统可以安装使用。
所以操作上完全不存在问题。
五:
主要数据
//MyQQServer.cpp:
Definestheclassbehaviorsfortheapplication.
//
#include"stdafx.h"
#include"MyQQServer.h"
#include"MyQQServerDlg.h"
#include"ClientSocket.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CMyQQServerApp
BEGIN_MESSAGE_MAP(CMyQQServerApp,CWinApp)
//{{AFX_MSG_MAP(CMyQQServerApp)
//NOTE-theClassWizardwilladdandremovemappingmacroshere.
//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!
//}}AFX_MSG
ON_COMMAND(ID_HELP,CWinApp:
:
OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CMyQQServerAppconstruction
CMyQQServerApp:
:
CMyQQServerApp()
{
//TODO:
addconstructioncodehere,
//PlaceallsignificantinitializationinInitInstance
m_pClientSocketList=newCPtrList();
}
/////////////////////////////////////////////////////////////////////////////
//TheoneandonlyCMyQQServerAppobject
CMyQQServerApptheApp;
CCriticalSectiong_cs;
/////////////////////////////////////////////////////////////////////////////
//CMyQQServerAppinitialization
BOOLCMyQQServerApp:
:
InitInstance()
{
if(!
AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
returnFALSE;
}
AfxEnableControlContainer();
AfxInitRichEdit();
m_af.Start("IDR_MATINURF_GTBASE",NULL,GTP_LOAD_RESOURCE,NULL,"MATINURF");
//Standardinitialization
//Ifyouarenotusingthesefeaturesandwishtoreducethesize
//ofyourfinalexecutable,youshouldremovefromthefollowing
//thespecificinitializationroutinesyoudonotneed.
#ifdef_AFXDLL
Enable3dControls();//CallthiswhenusingMFCinasharedDLL
#else
Enable3dControlsStatic();//CallthiswhenlinkingtoMFCstatically
#endif
CMyQQServerDlgdlg;
m_pMainWnd=&dlg;
intnResponse=dlg.DoModal();
if(nResponse==IDOK)
{
//TODO:
Placecodeheretohandlewhenthedialogis
//dismissedwithOK
}
elseif(nResponse==IDCANCEL)
{
//TODO:
Placecodeheretohandlewhenthedialogis
//dismissedwithCancel
}
//Sincethedialoghasbeenclosed,returnFALSEsothatweexitthe
//application,ratherthanstarttheapplication'smessagepump.
returnFALSE;
}
intCMyQQServerApp:
:
ExitInstance()
{
MessagemsObj;
msObj.iType=SYSERROR;
msObj.iSubType=SERVERQUIT;
CPtrList*m_pClientList=m_pClientSocketList;
POSITIONpos=m_pClientList->GetHeadPosition();
if(pos)
{
CClientSocket*m_pClientSocket;
for(inti=0;iGetCount();i++)
{
m_pClientSocket=static_cast(m_pClientList->GetNext(pos));
m_pClientSocket->Send(&msObj,sizeof(Message));
Sleep(100);
}
}
//删除
DeleteAllList();
returnCWinApp:
:
ExitInstance();
}
voidCMyQQServerApp:
:
DeleteAllList()
{
//删除
POSITIONpos=m_pClientSocketList->GetHeadPosition();
if(pos)
{
CClientSocket*m_pClientSocket;
for(inti=0;iGetCount();i++)
{
m_pClientSocket=static_cast(m_pClientSocketList->GetNext(pos));
ASSERT(m_pClientSocket!
=NULL);
ASSERT_VALID(m_pClientSocket);
deletem_pClientSocket;
}
}
deletem_pClientSocketList;
}
//MyQQClient.cpp:
Definestheclassbehaviorsfortheapplication.
//
#include"stdafx.h"
#include"MyQQClient.h"
#include"MyQQClientDlg.h"
#include"MainSocket.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CMyQQClientApp
BEGIN_MESSAGE_MAP(CMyQQClientApp,CWinApp)
//{{AFX_MSG_MAP(CMyQQClientApp)
//NOTE-theClassWizardwilladdandremovemappingmacroshere.
//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!
//}}AFX_MSG
ON_COMMAND(ID_HELP,CWinApp:
:
OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CMyQQClientAppconstruction
CMyQQClientApp:
:
CMyQQClientApp()
{
//TODO:
addconstructioncodehere,
//PlaceallsignificantinitializationinInitInstance
}
/////////////////////////////////////////////////////////////////////////////
//TheoneandonlyCMyQQClientAppobject
CMyQQClientApptheApp;
/////////////////////////////////////////////////////////////////////////////
//CMyQQClientAppinitialization
BOOLCMyQQClientApp:
:
InitInstance()
{
if(!
AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
returnFALSE;
}
AfxEnableControlContainer();
AfxInitRichEdit();
m_af.Start("IDR_MATINURF_GTBASE",NULL,GTP_LOAD_RESOURCE,NULL,"MATINURF");
//Standardinitialization
//Ifyouarenotusingthesefeaturesandwishtoreducethesize
//ofyourfinalexecutable,youshouldremovefromthefollowing
//thespecificinitializationroutinesyoudonotneed.
#ifdef_AFXDLL
Enable3dControls();//CallthiswhenusingMFCinasharedDLL
#else
Enable3dControlsStatic();//CallthiswhenlinkingtoMFCstatically
#endif
CMyQQClientDlgdlg;
m_pMainWnd=&dlg;
intnResponse=dlg.DoModal();
if(nResponse==IDOK)
{
//TODO:
Placecodeheretohandlewhenthedialogis
//dismissedwithOK
}
elseif(nResponse==IDCANCEL)
{
//TODO:
Placecodeheretohandlewhenthedialogis
//dismissedwithCancel
}
//Sincethedialoghasbeenclosed,returnFALSEsothatweexitthe
//application,ratherthanstarttheapplication'smessagepump.
returnFALSE;
}
intCMyQQClientApp:
:
ExitInstance()
{
returnCWinApp:
:
ExitInstance();
}
六:
程序运行的条件
✓网站打开
✓服务器打开
✓二个复制端口相同
✓多人进入聊天室
七:
源代码
服务编码
//MyQQServer.cpp:
Definestheclassbehaviorsfortheapplication.
//
#include"stdafx.h"
#include"MyQQServer.h"
#include"MyQQServerDlg.h"
#include"ClientSocket.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CMyQQServerApp
BEGIN_MESSAGE_MAP(CMyQQServerApp,CWinApp)
//{{AFX_MSG_MAP(CMyQQServerApp)
//NOTE-theClassWizardwilladdandremovemappingmacroshere.
//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!
//}}AFX_MSG
ON_COMMAND(ID_HELP,CWinApp:
:
OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CMyQQServerAppconstruction
CMyQQServerApp:
:
CMyQQServerApp()
{
//TODO:
addconstructioncodehere,
//PlaceallsignificantinitializationinInitInstance
m_pClientSocketList=newCPtrList();
}
/////////////////////////////////////////////////////////////////////////////
//TheoneandonlyCMyQQServerAppobject
CMyQQServerApptheApp;
CCriticalSectiong_cs;
/////////////////////////////////////////////////////////////////////////////
//CMyQQServerAppinitialization
BOOLCMyQQServerApp:
:
InitInstance()
{
if(!
AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
returnFALSE;
}
AfxEnableControlContainer();
AfxInitRichEdit();
m_af.Start("IDR_MATINURF_GTBASE",NULL,GTP_LOAD_RESOURCE,NULL,"MATINURF");
//Standardinitialization
//Ifyouarenotusingthesefeaturesandwishtoreducethesize
//ofyourfinalexecutable,youshouldremovefromthefollowing
//thespecificinitializationroutinesyoudonotneed.
#ifdef_AFXDLL
Enable3dControls();//CallthiswhenusingMFCinasharedDLL
#else
Enable3dControlsStatic();//CallthiswhenlinkingtoMFCstatically
#endif
CMyQQServerDlgdlg;
m_pMainW