• 大小: 11.10M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2020-12-27
  • 语言: Java
  • 标签: 聊天  java  聊天室  

资源简介

        使用Socket技术的在线即使聊天的demo

资源截图

代码片段和文件信息

package com.zhenzhigu.chat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;

import javax.websocket.OnClose;
import javax.websocket.onerror;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;

import net.sf.json.JSONobject;

@ServerEndpoint(“/websocket“)
public class ChatServer {

private static SimpleDateFormat df = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss“);
private static Vector room = new Vector();


/**
 * 用户接入
 * @param session 可选
 */
@OnOpen
public void onOpen(Session session){
room.addElement(session);
}

/**
 * 接收到来自用户的消息
 * @param message
 * @param session
 */
@OnMessage
public 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件          0  2018-04-09 14:23  WebSocketChat\.metadata\.lock

     文件       4330  2018-04-09 14:40  WebSocketChat\.metadata\.log

     文件        438  2018-04-09 14:24  WebSocketChat\.metadata\.mylyn\repositories.xml.zip

     文件       6485  2018-04-09 14:25  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.history\37\60320f14c03b001817d4f08e6432be8f

     文件       6322  2018-04-09 14:25  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.history\43\e0f90d14c03b001817d4f08e6432be8f

     文件       1579  2018-04-09 14:25  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.history\5c\90a70f14c03b001817d4f08e6432be8f

     文件        247  2018-04-09 14:40  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.history\8c\9043aaf0c03b001817d4f08e6432be8f

     文件       1393  2018-04-09 14:25  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.history\91\20960e14c03b001817d4f08e6432be8f

     文件        329  2018-04-09 14:40  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.history\98\f02dabf0c03b001817d4f08e6432be8f

     文件        419  2018-04-09 14:40  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.history\a7\a0dbacf0c03b001817d4f08e6432be8f

     文件      12257  2018-04-09 14:25  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.history\b6\a05d0d14c03b001817d4f08e6432be8f

     文件        143  2018-04-09 14:40  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.history\d2\100ba9f0c03b001817d4f08e6432be8f

     文件     168087  2018-04-09 14:25  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.history\f8\e06a1014c03b001817d4f08e6432be8f

     文件        395  2018-04-09 14:40  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.history\fe\40f1abf0c03b001817d4f08e6432be8f

     文件        491  2018-04-09 14:40  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.projects\Servers\.indexes\b3\history.index

     文件       4044  2018-04-09 14:42  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.projects\Servers\.syncinfo

     文件        172  2018-04-09 14:41  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.projects\testWebSocket\.indexes\af\history.index

     文件        678  2018-04-09 14:42  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.projects\testWebSocket\.markers

     文件       2013  2018-04-09 14:42  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.projects\testWebSocket\.syncinfo

     文件       4026  2018-04-09 14:42  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.projects\testWebSocket\org.eclipse.jdt.core\state.dat

     文件        123  2018-04-09 14:42  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.projects\testWebSocket\org.eclipse.wst.jsdt.core\state.dat

     文件      11195  2018-04-09 14:42  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.projects\WebSocketChat\.markers

     文件      77562  2018-04-09 14:42  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.projects\WebSocketChat\.syncinfo

     文件       4694  2018-04-09 14:42  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.projects\WebSocketChat\org.eclipse.jdt.core\state.dat

     文件     307098  2018-04-09 14:42  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.projects\WebSocketChat\org.eclipse.wst.jsdt.core\state.dat

     文件          1  2018-04-09 14:42  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.root\.indexes\history.version

     文件        282  2018-04-09 14:42  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.root\.indexes\properties.index

     文件          1  2018-04-09 14:42  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.root\.indexes\properties.version

     文件      12923  2018-04-09 14:42  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.root\1.tree

     文件       1885  2018-04-09 14:42  WebSocketChat\.metadata\.plugins\org.eclipse.core.resources\.safetable\org.eclipse.core.resources

............此处省略491个文件信息

评论

共有 条评论