websocket channel init enchance
This commit is contained in:
parent
24908aa309
commit
871e9224ca
|
@ -43,10 +43,13 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
|
|||
conn, _ := websocket.Upgrade(w, r, nil, 1024, 1024)
|
||||
editorChan := util.WSChannel{Sid: sid, Conn: conn, Request: r, Time: time.Now()}
|
||||
|
||||
session.EditorWS[sid] = &editorChan
|
||||
|
||||
ret := map[string]interface{}{"output": "Editor initialized", "cmd": "init-editor"}
|
||||
editorChan.Conn.WriteJSON(&ret)
|
||||
err := editorChan.Conn.WriteJSON(&ret)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
session.EditorWS[sid] = &editorChan
|
||||
|
||||
glog.Infof("Open a new [Editor] with session [%s], %d", sid, len(session.EditorWS))
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ package notification
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"strconv"
|
||||
"github.com/b3log/wide/conf"
|
||||
"github.com/b3log/wide/event"
|
||||
"github.com/b3log/wide/i18n"
|
||||
|
@ -97,6 +97,12 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
|
|||
conn, _ := websocket.Upgrade(w, r, nil, 1024, 1024)
|
||||
wsChan := util.WSChannel{Sid: sid, Conn: conn, Request: r, Time: time.Now()}
|
||||
|
||||
ret := map[string]interface{}{"notification": "Notification initialized", "cmd": "init-notification"}
|
||||
err := wsChan.Conn.WriteJSON(&ret)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
session.NotificationWS[sid] = &wsChan
|
||||
|
||||
glog.V(4).Infof("Open a new [Notification] with session [%s], %d", sid, len(session.NotificationWS))
|
||||
|
|
|
@ -58,10 +58,13 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
|
|||
conn, _ := websocket.Upgrade(w, r, nil, 1024, 1024)
|
||||
wsChan := util.WSChannel{Sid: sid, Conn: conn, Request: r, Time: time.Now()}
|
||||
|
||||
session.OutputWS[sid] = &wsChan
|
||||
|
||||
ret := map[string]interface{}{"output": "Ouput initialized", "cmd": "init-output"}
|
||||
wsChan.Conn.WriteJSON(&ret)
|
||||
err := wsChan.Conn.WriteJSON(&ret)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
session.OutputWS[sid] = &wsChan
|
||||
|
||||
glog.V(4).Infof("Open a new [Output] with session [%s], %d", sid, len(session.OutputWS))
|
||||
}
|
||||
|
|
|
@ -126,10 +126,13 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
|
|||
conn, _ := websocket.Upgrade(w, r, nil, 1024, 1024)
|
||||
wsChan := util.WSChannel{Sid: sid, Conn: conn, Request: r, Time: time.Now()}
|
||||
|
||||
SessionWS[sid] = &wsChan
|
||||
|
||||
ret := map[string]interface{}{"output": "Session initialized", "cmd": "init-session"}
|
||||
wsChan.Conn.WriteJSON(&ret)
|
||||
err := wsChan.Conn.WriteJSON(&ret)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
SessionWS[sid] = &wsChan
|
||||
|
||||
glog.V(4).Infof("Open a new [Session Channel] with session [%s], %d", sid, len(SessionWS))
|
||||
|
||||
|
|
|
@ -89,10 +89,13 @@ func WSHandler(w http.ResponseWriter, r *http.Request) {
|
|||
conn, _ := websocket.Upgrade(w, r, nil, 1024, 1024)
|
||||
wsChan := util.WSChannel{Sid: sid, Conn: conn, Request: r, Time: time.Now()}
|
||||
|
||||
ShellWS[sid] = &wsChan
|
||||
|
||||
ret := map[string]interface{}{"output": "Shell initialized", "cmd": "init-shell"}
|
||||
wsChan.Conn.WriteJSON(&ret)
|
||||
err := wsChan.Conn.WriteJSON(&ret)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
ShellWS[sid] = &wsChan
|
||||
|
||||
glog.V(4).Infof("Open a new [Shell] with session [%s], %d", sid, len(ShellWS))
|
||||
|
||||
|
|
|
@ -36,6 +36,10 @@ var notification = {
|
|||
$notification = $('.bottom-window-group .notification > table'),
|
||||
notificationHTML = '';
|
||||
|
||||
if (data.cmd && "init-notification" === data.cmd) {
|
||||
return;
|
||||
}
|
||||
|
||||
notificationHTML += '<tr><td class="severity">' + data.severity
|
||||
+ '</td><td class="message">' + data.message
|
||||
+ '</td><td class="type">' + data.type + '</td></tr>';
|
||||
|
|
Loading…
Reference in New Issue