forked from beyondfengyu/HappyChat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f7d33fa
Showing
106 changed files
with
2,805 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false"> | ||
<output url="file://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
<excludeFolder url="file://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.23" level="project" /> | ||
<orderEntry type="library" name="Maven: io.netty:netty-all:4.1.6.Final" level="project" /> | ||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.7" level="project" /> | ||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.7" level="project" /> | ||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.20" level="project" /> | ||
</component> | ||
</module> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.qqFace{margin-top:4px;background:#fff;padding:2px;border:1px #dfe6f6 solid;} | ||
.qqFace table td{padding:0px;} | ||
.qqFace table td img{cursor:pointer;border:1px #fff solid;} | ||
.qqFace table td img:hover{border:1px #0066cc solid;} | ||
.top{ | ||
padding:10px 0; | ||
background:transparent; | ||
background-color:rgba(0,0,0,0.4); | ||
} | ||
#userCount{ | ||
margin:0 2px; | ||
font-weight:bolder; | ||
font-size:16px; | ||
} | ||
#content{ | ||
width:100%; | ||
height:100%; | ||
padding:10px 15px; | ||
font-size:16px; | ||
overflow: auto; | ||
} | ||
.title{ | ||
padding: 4px 0 0; | ||
color: #1259d2; | ||
font-weight:bold; | ||
} | ||
.item{ | ||
font-family: "Microsoft YaHei UI"; | ||
padding:4px 4px 0; | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
/** | ||
* Created by yu on 2017/1/15. | ||
*/ | ||
var socket = null; | ||
var isAuth = false; | ||
var userNick = null; | ||
var userCount = 0; | ||
$(function () { | ||
$("#menuModal").modal('show'); | ||
var height = $(window).height(); | ||
$('#content').css("height", height - $('#top').height() - $('#opt').height() - 40); | ||
|
||
$('#loginBtn').click(function(){ | ||
userLogin(); | ||
}); | ||
|
||
$('#faceBtn').qqFace({ | ||
id: 'facebox', | ||
assign: 'mess', | ||
path: 'arclist/' //表情存放的路径 | ||
}); | ||
|
||
$('#sendBtn').click(function () { | ||
var mess = $("#mess").val().trim(); | ||
if(mess){ | ||
sendMess(mess); | ||
$("#mess").val(''); | ||
} | ||
}).keyup(function(e){ | ||
var keyCode = e.which || e.keyCode; | ||
if(keyCode==13){ | ||
$("#sendBtn").click(); | ||
} | ||
}); | ||
}); | ||
|
||
function sendMess(mess) { | ||
send(true, "{'code':10086,'mess':'"+mess+"'}"); | ||
} | ||
; | ||
|
||
|
||
function userLogin() { | ||
if (!userNick) { | ||
userNick = $('#nick').val().trim(); | ||
} | ||
if (userNick) { | ||
if (!window.WebSocket) { | ||
window.WebSocket = window.MozWebSocket; | ||
} | ||
if (window.WebSocket) { | ||
window.socket = new WebSocket("ws://chat.wolfbe.com:9688/websocket"); | ||
window.socket.onmessage = function (event) { | ||
var data = eval("(" + event.data + ")"); | ||
console.log("onmessage data: " + JSON.stringify(data)); | ||
switch (data.uri) { | ||
case 1 << 8 | 220: // ping message | ||
case 2 << 8 | 220: // pong message | ||
console.log("ping message: " + JSON.stringify(data)); | ||
pingInvake(data); | ||
break; | ||
case 3 << 8 | 220: // system message | ||
console.log("system message: " + JSON.stringify(data)); | ||
sysInvake(data); | ||
break; | ||
case 4 << 8 | 220: // error message | ||
console.log("error message: " + JSON.stringify(data)); | ||
closeInvake(null); | ||
break; | ||
case 5 << 8 | 220: // auth message | ||
console.log("auth message: " + JSON.stringify(data)); | ||
break; | ||
case 6 << 8 | 220: // broadcast message | ||
console.log("broadcast message: " + JSON.stringify(data)); | ||
broadcastInvake(data); | ||
break; | ||
|
||
} | ||
}; | ||
window.socket.onclose = function (event) { | ||
console.log("connection close!!!"); | ||
closeInvake(event); | ||
}; | ||
window.socket.onopen = function (event) { | ||
console.log("connection success!!"); | ||
openInvake(event); | ||
}; | ||
} else { | ||
alert("您的浏览器不支持WebSocket!!!"); | ||
} | ||
} else { | ||
$('#tipMsg').text("请输入昵称"); | ||
$('#tipModal').modal('show'); | ||
} | ||
} | ||
|
||
function send(auth, mess) { | ||
if (!window.socket) { | ||
return; | ||
} | ||
if (socket.readyState == WebSocket.OPEN || auth) { | ||
console.log("send: " + mess); | ||
window.socket.send(mess); | ||
} else { | ||
$('#tipMsg').text("连接没有成功,请重新登录"); | ||
$('#tipModal').modal('show'); | ||
} | ||
} | ||
; | ||
|
||
function openInvake(event) { | ||
var obj = {}; | ||
obj.code = 10000; | ||
obj.nick = $('#nick').val().trim(); | ||
send(true, JSON.stringify(obj)); | ||
} | ||
; | ||
|
||
|
||
function closeInvake(event) { | ||
window.socket = null; | ||
window.isAuth = false; | ||
window.userCount = 0; | ||
$('#tipMsg').text("登录失败,网络连接异常"); | ||
$('#tipModal').modal('show'); | ||
} | ||
; | ||
|
||
/** | ||
* 处理系统消息 | ||
* @param data | ||
*/ | ||
function sysInvake(data) { | ||
switch (data.extend.code) { | ||
case 20001: // user count | ||
console.log("current user: " + data.extend.mess); | ||
userCount = data.extend.mess; | ||
$('#userCount').text(userCount); | ||
break; | ||
case 20002: // auth | ||
console.log("auth result: " + data.extend.mess); | ||
isAuth = data.extend.mess; | ||
if (isAuth) { | ||
$("#menuModal").modal('hide'); | ||
$('#chatWin').show(); | ||
$('#content').append('欢迎来到嗨皮聊天室!!'); | ||
// $('#content').scrollTop($('#content')[0].scrollHeight); | ||
} | ||
break; | ||
case 20003: // system message | ||
console.log("system message: " + data.extend.mess); | ||
break; | ||
} | ||
} | ||
; | ||
|
||
/** | ||
* 处理广播消息 | ||
* @param data | ||
*/ | ||
function broadcastInvake(data) { | ||
var mess = data.body; | ||
var nick = data.extend.nick; | ||
var uid = data.extend.uid; | ||
var time = data.extend.time; | ||
mess = replace_em(mess); | ||
var html = '<div class="title">'+nick+' ('+uid+') '+time+'</div><div class="item">'+mess+'</div>'; | ||
$("#content").append(html); | ||
$('#content').scrollTop($('#content')[0].scrollHeight); | ||
|
||
} | ||
; | ||
|
||
function erorInvake(data) { | ||
|
||
} | ||
; | ||
|
||
/** | ||
* 处理ping消息 | ||
* @param data | ||
*/ | ||
function pingInvake(data) { | ||
//发送pong消息响应 | ||
send(isAuth, "{'code':10016}"); | ||
} | ||
; | ||
//查看结果 | ||
function replace_em(str) { | ||
str = str.replace(/\</g, '<'); | ||
str = str.replace(/\>/g, '>'); | ||
str = str.replace(/\n/g, '<br/>'); | ||
str = str.replace(/\[em_([0-9]*)\]/g, '<img src="arclist/$1.gif" border="0" />'); | ||
return str; | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// QQ表情插件 | ||
(function($){ | ||
$.fn.qqFace = function(options){ | ||
var defaults = { | ||
id : 'facebox', | ||
path : 'face/', | ||
assign : 'content', | ||
tip : 'em_' | ||
}; | ||
var option = $.extend(defaults, options); | ||
var assign = $('#'+option.assign); | ||
var id = option.id; | ||
var path = option.path; | ||
var tip = option.tip; | ||
|
||
if(assign.length<=0){ | ||
alert('缺少表情赋值对象。'); | ||
return false; | ||
} | ||
|
||
$(this).click(function(e){ | ||
var strFace, labFace; | ||
if($('#'+id).length<=0){ | ||
strFace = '<div id="'+id+'" style="position:fixed;display:none;z-index:1000;" class="qqFace">' + | ||
'<table border="0" cellspacing="0" cellpadding="0"><tr>'; | ||
for(var i=1; i<=75; i++){ | ||
labFace = '['+tip+i+']'; | ||
strFace += '<td><img src="'+path+i+'.gif" onclick="$(\'#'+option.assign+'\').setCaret();$(\'#'+option.assign+'\').insertAtCaret(\'' + labFace + '\');" /></td>'; | ||
if( i % 15 == 0 ) strFace += '</tr><tr>'; | ||
} | ||
strFace += '</tr></table></div>'; | ||
} | ||
$(this).parent().append(strFace); | ||
var offset = $(this).position(); | ||
var top = offset.top + $(this).outerHeight(); | ||
$('#'+id).css('bottom',top + 10); | ||
$('#'+id).css('left',offset.left); | ||
$('#'+id).show(); | ||
e.stopPropagation(); | ||
}); | ||
|
||
$(document).click(function(){ | ||
$('#'+id).hide(); | ||
$('#'+id).remove(); | ||
}); | ||
}; | ||
|
||
})(jQuery); | ||
|
||
jQuery.extend({ | ||
unselectContents: function(){ | ||
if(window.getSelection) | ||
window.getSelection().removeAllRanges(); | ||
else if(document.selection) | ||
document.selection.empty(); | ||
} | ||
}); | ||
jQuery.fn.extend({ | ||
selectContents: function(){ | ||
$(this).each(function(i){ | ||
var node = this; | ||
var selection, range, doc, win; | ||
if ((doc = node.ownerDocument) && (win = doc.defaultView) && typeof win.getSelection != 'undefined' && typeof doc.createRange != 'undefined' && (selection = window.getSelection()) && typeof selection.removeAllRanges != 'undefined'){ | ||
range = doc.createRange(); | ||
range.selectNode(node); | ||
if(i == 0){ | ||
selection.removeAllRanges(); | ||
} | ||
selection.addRange(range); | ||
} else if (document.body && typeof document.body.createTextRange != 'undefined' && (range = document.body.createTextRange())){ | ||
range.moveToElementText(node); | ||
range.select(); | ||
} | ||
}); | ||
}, | ||
|
||
setCaret: function(){ | ||
if(!$.browser.msie) return; | ||
var initSetCaret = function(){ | ||
var textObj = $(this).get(0); | ||
textObj.caretPos = document.selection.createRange().duplicate(); | ||
}; | ||
$(this).click(initSetCaret).select(initSetCaret).keyup(initSetCaret); | ||
}, | ||
|
||
insertAtCaret: function(textFeildValue){ | ||
var textObj = $(this).get(0); | ||
if(document.all && textObj.createTextRange && textObj.caretPos){ | ||
var caretPos=textObj.caretPos; | ||
caretPos.text = caretPos.text.charAt(caretPos.text.length-1) == '' ? | ||
textFeildValue+'' : textFeildValue; | ||
} else if(textObj.setSelectionRange){ | ||
var rangeStart=textObj.selectionStart; | ||
var rangeEnd=textObj.selectionEnd; | ||
var tempStr1=textObj.value.substring(0,rangeStart); | ||
var tempStr2=textObj.value.substring(rangeEnd); | ||
textObj.value=tempStr1+textFeildValue+tempStr2; | ||
textObj.focus(); | ||
var len=textFeildValue.length; | ||
textObj.setSelectionRange(rangeStart+len,rangeStart+len); | ||
textObj.blur(); | ||
}else{ | ||
textObj.value+=textFeildValue; | ||
} | ||
} | ||
}); |
Oops, something went wrong.