【正文】
ient side sends, and can renovate the users tabulation. The latter make a connection with the server, carries on munication between the client side and the client side. With the LAN correspondence mechanism principle, through inheritting the Thread kind to establish the multithreading directly. In the development, it uses the elementary theory knowledge which the puter network programmes. for example, TCP/IP agreement, Client/Server pattern, network programming design method and so on. In the network programming, it realizes reading and transmission of the information, that is,informaton flows realize the information exchange, introduce information flow analysis for realizing a system, in which containes some basic software engineering methods. After analyzes these situations, this chating tool takes Eclipse as the basic development environment and piles in java language. first, it will establish the system application prototype in a short time. then, for the initial prototype system, it needs constantly revised and improved, until a viable system.Keywords: Instant Messaging System。其中用到了局域網(wǎng)通信機制的原理,通過直接繼承Thread類來建立多線程。目前,出現(xiàn)了很多非常不錯的聊天工具,其中應用比較廣泛的有Netmeeting、騰訊、MSNMessager等等。該系統(tǒng)開發(fā)主要包括一個網(wǎng)絡聊天服務器程序和一個網(wǎng)絡聊天客戶程序兩個方面。開發(fā)中利用了計算機網(wǎng)絡編程的基本理論知識,如TCP/IP協(xié)議、客戶端/服務器端模式(Client/Server模式)、網(wǎng)絡編程的設計方法等。 C/S 。目前,出現(xiàn)了很多非常不錯的聊天工具,其中應用比較廣泛的有Netmeeting、騰訊、MSNMessager等等。使用它可在各式各樣不同種機器、不同種操作平臺的網(wǎng)絡環(huán)境中開發(fā)軟件。 開發(fā)目的和意義網(wǎng)絡通信在當今信息社會中起著不可或缺的作用,人們可以利用網(wǎng)絡通信技術進行即時的信息 交流。考慮到要可以在局域網(wǎng)中應用,本系統(tǒng)使用的是第二種方法,經(jīng)過設置,在局域網(wǎng)或internet上都可以使用。它以抽象窗口工具包(AWT)為基礎使跨平臺應用程序可以使用任何可插拔的外觀風格。 C/S開發(fā)模式 C/S結構的優(yōu)點是能充分發(fā)揮客戶端PC的處理能力,很多工作可以在客戶端處理后再提交給服務器。 客戶端需要安裝專用的客戶端軟件。可能適應于win7,但不能用于Windows 2000或Windows XP。在聊天頁面上,有發(fā)送文字,發(fā)送截圖,和發(fā)送文件的功能按鈕。 Socket通信技術Socket程序的工作過程:建立Socket連接:在通信開始之前由通信雙方確認身份,建立一條專用的虛擬連接通道。還有,收發(fā)消息時,可以實現(xiàn)離線接收。因此技術上是可以實現(xiàn)的。如果要實現(xiàn)internet上通訊,只需要將服務器端運行在一個有固定IP的公網(wǎng)上就可以。2)登陸在客戶端,用戶輸入其號碼和密碼,然后建立與服務器的連接,告訴服務器我要登錄,服務器收到后,開始通過JDBC讀取數(shù)據(jù)庫,然后與用戶輸入的信息進行比對,如果成功,便打開主程序窗口。如果B不在線則把信息儲存在服務器,等B上線了在發(fā)送給他。B接收到A發(fā)來的截圖信息,會根據(jù)byte[]構造圖片,將圖片顯示出來。B接收到A發(fā)來的文件信息,會根據(jù)文件發(fā)送的狀態(tài)和byte[]構造文件。8)在線用戶的操作 管理員通過B/S的系統(tǒng)對在線用戶操作,可以踢用戶下線。如果登陸成功,就更新在線狀態(tài)。此包中包含接收者的信息,如果接收者在線,數(shù)據(jù)包將會轉(zhuǎn)發(fā)到接收者。線程類為ClientThread:表43 ClientThread類屬性名作用public void notifyOnline()通知其他線程,自己上線了,讓客戶方更新頭像public void run() 線程的主題,轉(zhuǎn)發(fā)消息public void notifyOffline(){通知其他線程,自己下線了,讓客戶方更新頭像public void send(Object o) 發(fā)送消息public Object receive() 接收消息 客戶端線程類設計屬性名作用public int login (String username,String password)傳入帳號密碼給服務器端驗證public void run() 線程的主題,讀取服務器端發(fā)來的資料并顯示相關內(nèi)容public void sendMsg2Server(byte[]data)向服務器端發(fā)送信息public void sendCheckMsg2Server()向服務器發(fā)送確認信息,確保鏈路通暢public void MonitorThread()檢測連接狀態(tài),確保鏈路通暢 實現(xiàn)概況本系統(tǒng)可分為登錄、聊天、文件、用戶管理和注冊五個功能模塊。 注冊模塊 流程圖圖 51 用戶注冊流程圖 關鍵代碼public class Regist { private Socket socket =