当前位置: 代码迷 >> Eclipse >> 模拟qq聊天,麻烦给一下思路解决方案
  详细解决方案

模拟qq聊天,麻烦给一下思路解决方案

热度:45   发布时间:2016-04-23 13:57:04.0
模拟qq聊天,麻烦给一下思路
模仿QQ的部分功能,建立一个功能全面的网络聊天程序,可以实现多人聊天,并可以保存聊天记录。
功能要求:1)多线程聊天程序
2)可以接收多人聊天
3)可以发送文件
4)可以发送图片
5)可以保存聊天记录
6)要求界面美观、布局合理、功能操作简便
   

麻烦给一下思路,本人菜鸟,呵呵


------解决方案--------------------
Java code
/** * 网络聊天室过服务端 */import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.io.PrintWriter;import java.net.ServerSocket;import java.net.Socket;import java.util.ArrayList;import java.util.Date;import java.util.List;public class Server {    private static String information = "";    static List<PrintWriter> outs = new ArrayList<PrintWriter>();    public static void main(String[] args) throws IOException {        ServerSocket ss = new ServerSocket(9800);        while(true){            Socket s = ss.accept();            new ServerThread(s).start();        }    }    static class ServerThread extends Thread{        private Socket s;                public ServerThread(Socket s){            this.s = s;        }        public void run(){            try {                BufferedReader in = new BufferedReader(                        new InputStreamReader(s.getInputStream()));                PrintWriter out = new PrintWriter(s.getOutputStream());                outs.add(out);                while(true){                    String word = in.readLine();                    information =(word+"\n");                    System.out.println(this.getName()+":"+information);                                        //得到所有用户的out                    for(PrintWriter o:outs){                        o.println(information);                        o.flush();                    }                }            } catch (IOException e) {                e.printStackTrace();            }        }    }}
------解决方案--------------------
http://javafound.iteye.com/blog/669508


里面有设计

http://javafound.iteye.com/?page=2
------解决方案--------------------
利用socket通信,可以通过多次登录,打开多个实例来模拟实现多人聊天,不过它们的ip地址是相同的。本人菜鸟,也就知道这么多了。
------解决方案--------------------
可以参考 Spark的实现。 这是一个开源的 IM 软件。 
 http://www.igniterealtime.org/projects/spark/index.jsp
------解决方案--------------------
你可以在我的资源里面去下,里面包含了我们当时所有的开发文档,当然也有源码,你可以先尝试根据开发文档自行开发,然后参考那个代码。环境是java,工具eclipse!
  相关解决方案