-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
去掉socket.io,增加javax.websocket,开启websocket后重启服务不用再等待ws服务停止了
- Loading branch information
Showing
23 changed files
with
466 additions
and
342 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
51 changes: 0 additions & 51 deletions
51
src/main/java/co/yiiu/pybbs/config/websocket/BindDataListener.java
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
src/main/java/co/yiiu/pybbs/config/websocket/MessageDecoder.java
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,30 @@ | ||
package co.yiiu.pybbs.config.websocket; | ||
|
||
import co.yiiu.pybbs.util.Message; | ||
import com.alibaba.fastjson.JSON; | ||
|
||
import javax.websocket.Decoder; | ||
import javax.websocket.EndpointConfig; | ||
|
||
public class MessageDecoder implements Decoder.Text<Message> { | ||
@Override | ||
public Message decode(String s) { | ||
return JSON.parseObject(s, Message.class); | ||
} | ||
|
||
@Override | ||
public boolean willDecode(String s) { | ||
// 验证json字符串是否合法,合法才会进入decode()方法进行转换,不合法直接抛异常 | ||
return JSON.isValid(s); | ||
} | ||
|
||
@Override | ||
public void init(EndpointConfig endpointConfig) { | ||
|
||
} | ||
|
||
@Override | ||
public void destroy() { | ||
|
||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/co/yiiu/pybbs/config/websocket/MessageEncoder.java
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,24 @@ | ||
package co.yiiu.pybbs.config.websocket; | ||
|
||
import co.yiiu.pybbs.util.Message; | ||
import com.alibaba.fastjson.JSON; | ||
|
||
import javax.websocket.Encoder; | ||
import javax.websocket.EndpointConfig; | ||
|
||
public class MessageEncoder implements Encoder.Text<Message> { | ||
@Override | ||
public String encode(Message o) { | ||
return JSON.toJSONString(o); | ||
} | ||
|
||
@Override | ||
public void init(EndpointConfig endpointConfig) { | ||
|
||
} | ||
|
||
@Override | ||
public void destroy() { | ||
|
||
} | ||
} |
Oops, something went wrong.