diff --git a/api.go b/api.go
index 3878465..fddc5ac 100644
--- a/api.go
+++ b/api.go
@@ -251,7 +251,13 @@ func apiStart(br *broker) {
authorized.GET("/connect/:devid", func(c *gin.Context) {
if c.GetHeader("Upgrade") != "websocket" {
- c.Redirect(http.StatusFound, "/rtty/"+c.Param("devid"))
+ devid := c.Param("devid")
+ if _, ok := br.devices[devid]; !ok {
+ c.Redirect(http.StatusFound, "/error/offline")
+ return
+ }
+
+ c.Redirect(http.StatusFound, "/rtty/"+devid)
return
}
serveUser(br, c)
diff --git a/http.go b/http.go
index 58f3d29..743e1cc 100644
--- a/http.go
+++ b/http.go
@@ -303,7 +303,7 @@ func httpProxyRedirect(br *broker, c *gin.Context) {
_, ok := br.devices[devid]
if !ok {
- c.Status(http.StatusNotFound)
+ c.Redirect(http.StatusFound, "/error/offline")
return
}
diff --git a/ui/src/router/index.js b/ui/src/router/index.js
index 193e7e8..361e95d 100644
--- a/ui/src/router/index.js
+++ b/ui/src/router/index.js
@@ -9,6 +9,7 @@ import axios from 'axios'
import Login from '../views/Login.vue'
import Home from '../views/Home.vue'
import Rtty from '../views/Rtty.vue'
+import Error from '../views/Error.vue'
const routes = [
{
@@ -26,6 +27,12 @@ const routes = [
name: 'Rtty',
component: Rtty,
props: true
+ },
+ {
+ path: '/error/:err',
+ name: 'Error',
+ component: Error,
+ props: true
}
]
diff --git a/ui/src/views/Error.vue b/ui/src/views/Error.vue
new file mode 100644
index 0000000..5735881
--- /dev/null
+++ b/ui/src/views/Error.vue
@@ -0,0 +1,39 @@
+
+
+
Oops...
+
{{ message }}
+
+
+
+
+
+
diff --git a/ui/src/views/Rtty.vue b/ui/src/views/Rtty.vue
index 995778c..3b4d09f 100644
--- a/ui/src/views/Rtty.vue
+++ b/ui/src/views/Rtty.vue
@@ -242,12 +242,10 @@ export default {
const msg = JSON.parse(data)
if (msg.type === 'login') {
if (msg.err === LoginErrorOffline) {
- this.$message.error(this.$t('Device offline'))
- this.$router.push('/')
+ this.$router.push('/error/offline')
return
} else if (msg.err === LoginErrorBusy) {
- this.$message.error(this.$t('Sessions is full'))
- this.$router.push('/')
+ this.$router.push('/error/full')
return
}