diff options
Diffstat (limited to 'src/rhimportd/ctrlWebSocket.go')
-rw-r--r-- | src/rhimportd/ctrlWebSocket.go | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/rhimportd/ctrlWebSocket.go b/src/rhimportd/ctrlWebSocket.go index e764085..1ce0f80 100644 --- a/src/rhimportd/ctrlWebSocket.go +++ b/src/rhimportd/ctrlWebSocket.go @@ -25,17 +25,18 @@ package main import ( - "code.helsinki.at/rhrd-go/rddb" - "code.helsinki.at/rhrd-go/rhimport" "encoding/json" "fmt" - "github.com/gorilla/websocket" "html" "io" "io/ioutil" "math" "net/http" "time" + + "code.helsinki.at/rhrd-go/rddb" + "code.helsinki.at/rhrd-go/rhimport" + "github.com/gorilla/websocket" ) type webSocketRequestData struct { @@ -224,7 +225,7 @@ func webSocketDone(res rhimport.Result, userdata interface{}) bool { return true } -func (self *webSocketSession) startNewSession(reqdata *webSocketRequestData, binchan <-chan []byte, conf *rhimport.Config, sessions *rhimport.SessionStoreChan) (int, string) { +func (self *webSocketSession) startNewSession(reqdata *webSocketRequestData, conf *rhimport.Config, sessions *rhimport.SessionStoreChan) (int, string) { ctx := rhimport.NewContext(conf, nil) ctx.UserName = reqdata.UserName ctx.Password = reqdata.Password @@ -240,7 +241,6 @@ func (self *webSocketSession) startNewSession(reqdata *webSocketRequestData, bin ctx.AutotrimLevel = reqdata.AutotrimLevel ctx.UseMetaData = reqdata.UseMetaData ctx.SourceUri = reqdata.SourceUri - ctx.AttachmentChan = binchan id, s, code, errstring := sessions.New(ctx, reqdata.RefId) if code != http.StatusOK { @@ -302,7 +302,7 @@ func webSocketListUpdate(added, removed map[string]string, userdata interface{}) return true } -func webSocketSessionHandler(reqchan <-chan webSocketRequestData, binchan <-chan []byte, ws *websocket.Conn, conf *rhimport.Config, sessions *rhimport.SessionStoreChan) { +func webSocketSessionHandler(reqchan <-chan webSocketRequestData, ws *websocket.Conn, conf *rhimport.Config, sessions *rhimport.SessionStoreChan) { defer ws.Close() closed := make(chan bool, 1) @@ -325,7 +325,7 @@ func webSocketSessionHandler(reqchan <-chan webSocketRequestData, binchan <-chan if session.id != "" { sendWebSocketErrorResponse(ws, http.StatusBadRequest, "This connection already handles a session") } else { - code, errstring := session.startNewSession(&reqdata, binchan, conf, sessions) + code, errstring := session.startNewSession(&reqdata, conf, sessions) if code != http.StatusOK { sendWebSocketErrorResponse(ws, code, errstring) } else { @@ -389,10 +389,8 @@ func webSocketHandler(conf *rhimport.Config, db *rddb.DBChan, sessions *rhimport } rhdl.Println("WebSocket Client", ws.RemoteAddr(), "connected") reqchan := make(chan webSocketRequestData) - binchan := make(chan []byte) - go webSocketSessionHandler(reqchan, binchan, ws, conf, sessions) + go webSocketSessionHandler(reqchan, ws, conf, sessions) defer close(reqchan) - defer close(binchan) for { t, r, err := ws.NextReader() |