freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

基于java實現(xiàn)聊天室范文畢業(yè)論文-閱讀頁

2025-06-13 22:34本頁面
  

【正文】 })。 (label1)。 (button2)。 服務器轉(zhuǎn)發(fā)信息public void run(){ try{ while(true){ for(int i=0。i++){ Thread1=(CommunicateThread)(i)。 ClientName=(String)(i)。j()。 broadcastInfor=ClientName++string。 } ()。 }catch(InterruptedException ex){} } }catch(Exception e){} }}首先,服務器端得到每個連接上的客戶端信息棧,讀取每個連接線程信息棧并把信息發(fā)送出去。 服務器顯示在線用戶人數(shù)public void notifyRoom(){ StringBuffer people=new StringBuffer(PEOPLE)。 String constr=”當前在線人數(shù)為+ activeConnects”。 for(int i=0。i++){ Connect c=(Connect)(i)。 } sendClients(people)。圖 16: 管理員登錄界面進入到服務器端后啟動服務器。圖 17: 系統(tǒng)服務器端用戶可以通過登錄界面進入到聊天室,即系統(tǒng)的客戶端。圖 18: 系統(tǒng)客戶端若在運行過程中有用戶退出客戶端,則服務器端會有該用戶已退出的提示,并且當前在線人數(shù)會自動減 1,在此為 user2 退出。圖 20: 服務器被停止圖 21: 服務器停止后的客戶端結(jié) 束 語本課題是利用 Java,基于 C/S 開發(fā)的網(wǎng)上聊天室。本課題的完成,綜合運用了大學的專業(yè)課知識,特別是軟件工程、Java 等與系統(tǒng)設計有緊密聯(lián)系的知識,并加強了對實際問題的分析和解決能力,做到理論聯(lián)系實際。在本次的系統(tǒng)設計中,出現(xiàn)了有很多不足和需要改善的地方,這在以后的設計中都需要重點注意并加以改善,如:對代碼某些功能和屬性認識不清楚,在代碼編寫過程中,經(jīng)常會出現(xiàn)因為用錯代碼,而使系統(tǒng)產(chǎn)生錯誤。這些在聊天室中都是必須具有的功能。通過本次的畢業(yè)設計,使我對一個應用系統(tǒng)的開發(fā)有了進一步的了解,對軟件開發(fā)的過程也有了較深的認識。其功能基本符合系統(tǒng)開發(fā)前所撰寫的用戶需求分析的要求,能夠初步完成基于 C/S 的 Java 聊天室的相關(guān)功能。但是,這次畢業(yè)設計的完成,使我鞏固和加深了專業(yè)知識并積累了一次軟件開發(fā)的寶貴經(jīng)驗,這對我以后的工作和學習都有很大的實際意義的幫助。從論文的選題到定稿,他都進行了全面、具體、精心的指導,并為我提供了良好的條件。在與吳老師交流的三個月里,我不僅學到了專業(yè)知識,更重要的是學到了嚴謹?shù)闹螌W態(tài)度、認真的工作作風和不斷進取的精神。其次,我要感謝大學四年來向我授過課的老師,他們讓我學到了很多寶貴的知識。最后,我要再次向指導老師吳其林老師、學校的老師和親愛的同學表示深深的謝意!作者:***2022 年 5 月 10 號附 錄附錄 A 源程序主要代碼import .*。import .*。public class ChatRoomServer extends Frame implements Runnable{ Panel panel。 TextArea textArea。 // ServerSocket ServerSock。//默認端口號 Thread chatAcceptThread。//廣播 thread。//記錄連接的線程 ClientsInfor。 public ChatRoomServer(){ try{ jbInit()。 } ServerListen()。 sPanel=new ScrollPane()。 button1=new Button(退出)。 (new (){//退出按鈕注冊 public void actionPerformed(ActionEvent e){ button1_actionPerformed(e)。 (button1)。//注冊到繼承了窗口適配器的類 (600,600)。 (sPanel,)。 ()。 }public void processMsg(String str){// (str)。 }catch(IOException e){ processMsg(())。 } processMsg(Server listening on port:+DEFAULT_PORT)。 ClientsInfor=new ()。//啟動接受連接的線程 ()。//廣播線程 ()。 try{ while(true){ Socket ClientSock=()。//創(chuàng)建線程保持連接 (ct)。 i++。//version2 (Thread+i)。} }catch(IOException e){ processMsg(())。 try{ ()。 } }public static void main(String[] args){ ChatRoomServer chat=new ChatRoomServer()。 protected BufferedReader in=null。 ChatRoomServer chatFrame。//run() inforStack。//public CommunicateThread(Socket Sock,ChatRoomServer cFrame,int index){ ClientSock=Sock。 index2=index。 try{ in=new BufferedReader(new InputStreamReader(()))。 }catch(IOException ei){ try{ ()。 return。 }public void run(){ String infor。 if((Client exit!)){ writeInformation(infor)。 }else if(infor!=null){ writeInformation(infor)。 try{ (100)。} finally{ try{ ()。 ()。//在 Clients 中清除本線程序 。} } }public void writeInformation(String infor){//寫信息棧 (infor)。 }public void sendInformation(String str){//發(fā)送信息 try{ (str)。 }catch(Exception e){。 chatClients。//信息棧 ClientMsg。 CommunicateThread Thread2。//information in inforStack String ClientName。//broadcast information=ClientName+string。 chatClients=。 //()。k()。 (str)。i()。 msgStack=。//客戶名 //讀取每個連接線程的信息棧并把信息發(fā)送出去 for(int j=0。j++){ string=(String)(j)。 broadcast(broadcastInfor)。//清除以發(fā)送的信息} try{ (100)。 public ChatFrame_WindowAdapter(ChatRoomServer chatFrame){ =chatFrame。//reference to the method exit() in ChatRoomServer. }}import .*。import .*。public class ChatRoomClient extends Frame implements Runnable{ Panel panel1,panel2。 TextField textField1,textField2。 TextArea textArea。 // PrintWriter out。 Socket sock。 //create Thread to Read information from Server Thread readThread。//thread can go on runing ??public ChatRoomClient(){ try{ jbInit()。 } } public static void main(String[] args){//main method ChatRoomClient c=new ChatRoomClient()。 } private void jbInit(){//should set size,position and Font of every ponentbutton1=new Button(連接)。 textField1=new TextField(input Server address here!)。 label1=new Label(消息:)。 panel2=new Panel()。 textArea=new TextArea()。 } })。be registered to KeyListener. //press key:Enter to connect the Client to Server (new textField1_KeyAdapter(this))。 (textField1)。//panel2 //press button2: 發(fā)送 to send message (new (){ public void actionPerformed(ActionEvent e){ button2_actionPerformed(e)。 //textField2:for input message。 (label1)。 (button2)。//frame is registered to WindowListener (new BorderLayout())。 (panel1,)。 (panel2,)。 if(sock!=null){//connection successed processMsg(Connect successfully!)。 out=new PrintWriter(())。 processMsg(Connect failed!)。 ()。 ()。 }private void button2_actionPerformed(ActionEvent e){//發(fā)送按鈕 sendInformation()。 } public void processMsg(String msg){//客戶端處理消息 (msg)。 }public void run(){ String msg。 while(isTrue){ try{ msg=()。 stopRun()。 } (1000)。 }catch(InterruptedException ei){ processMsg(())。 try{//服務器退出關(guān)閉連接和相關(guān)的流 ()。 ()。 ()。 try{//close IOstream ()。 ()。 } }}//文本筐 textField1 的鍵擊事件適配器class textField1_KeyAdapter extends { ChatRoomClient chatFrame。 }public void keyPressed(KeyEvent e){//輸入的是 enter,開始連接! int j=()。 } }}//文本筐 textField2 的鍵擊事件適配器class textField2_KeyAdapter extends { ChatRoomClient chatFrame。 } public void keyPressed(KeyEvent e){//鍵擊 Enter 鍵,發(fā)送信息! int j=()。 } }}//窗口關(guān)閉事件適配器class ChatFrame_WindowAdapter extends { ChatRoomClient chatFrame。 } public void windowClosing(WindowEvent e){//exit program
點擊復制文檔內(nèi)容
規(guī)章制度相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1