Skip to content

Commit

Permalink
1.0.6版最新DEMO例子更新
Browse files Browse the repository at this point in the history
  • Loading branch information
linzhefeng78 committed May 6, 2021
1 parent 86d57ad commit 17d1725
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ websocket-spring-boot-starter [![License](http://img.shields.io/:license-apache-
<dependency>
<groupId>com.github.lazyboyl</groupId>
<artifactId>websocket-spring-boot-starter</artifactId>
<version>1.0.5.RELEASE</version>
<version>1.0.6.RELEASE</version>
</dependency>
```

Expand Down Expand Up @@ -252,6 +252,8 @@ websocket:
```
---
### 版本更新
#### 1.0.6.RELEASE
- 【BUG修复】全局异常补获无入参时异常不补获BUG修复。
#### 1.0.5.RELEASE
- 【新增】新增全局异常补获的机制。
#### 1.0.4.RELEASE
Expand Down
2 changes: 1 addition & 1 deletion vue-example/netty-websocket-vue-back/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>com.github.lazyboyl</groupId>
<artifactId>websocket-spring-boot-starter</artifactId>
<version>1.0.4.RELEASE</version>
<version>1.0.6.RELEASE</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import com.github.lazyboyl.websocket.integrate.EnableWebSocketServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@EnableWebSocketServer(webSocketScanPackage = {"com.vue.demo.vue"})
@ComponentScan({"com.lazyboyl.starter.demo","com.vue.demo.vue"})
public class VueDemoApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ public class UserController {
@Value("${user.info}")
private String info;

/**
* 抛出异常,用于全局异常补获
*/
@WebSocketRequestMapping("throwException")
public Map throwException(){
throw new RuntimeException("我出错了");
}

/**
* 批量推送当前登录用户的信息
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.vue.demo.vue.exception;

import com.github.lazyboyl.websocket.exception.WebsocketGlobalException;

import java.util.HashMap;
import java.util.Map;

/**
* @author linzf
* @since 2021/5/6
* 类描述:
*/
public class WebsocketGlobalExceptionImpl implements WebsocketGlobalException {

@Override
public int level() {
return 0;
}

@Override
public Object errorHandler(Exception e) {
Map<String,Object> r = new HashMap<>();
r.put("code",200);
r.put("result","失败了");
return r;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<button @click="getOrgVo">getOrgVo</button>
<button @click="getUserVoByUserIdRename">getUserVoByUserIdRename</button>
<button @click="sendMsg">sendMsg</button>
<button @click="throwException">throwException</button>
</div>
</template>

Expand All @@ -25,6 +26,10 @@
this.initWebSocket()
},
methods: {
throwException() {
let actions = {'url': '/user/throwException/', 'params': {}}
this.websocketsend(JSON.stringify(actions))
},
getUserVoByUserIdRename() {
let actions = {
'url': '/user/getUserVoByUserIdRename/',
Expand All @@ -33,7 +38,7 @@
this.websocketsend(JSON.stringify(actions))
},
getOrgVo() {
let actions = {'url': '/org/getOrgVo111/', 'params': {'orgId': 'sada11d', 'orgName': '林泽锋'}}
let actions = {'url': '/org/getOrgVo/', 'params': {'orgId': 'sada11d', 'orgName': '林泽锋'}}
this.websocketsend(JSON.stringify(actions))
},
getUserVoByUserList() {
Expand Down

0 comments on commit 17d1725

Please sign in to comment.