|
|
|
@ -3,21 +3,25 @@ package socket
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"net/http"
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/gorilla/websocket"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type WebsocketInterface struct {
|
|
|
|
|
Writer http.ResponseWriter
|
|
|
|
|
Request *http.Request
|
|
|
|
|
OnConnect func(who *websocket.Conn)
|
|
|
|
|
OnMessage func(who *websocket.Conn, msg string)
|
|
|
|
|
Writer http.ResponseWriter
|
|
|
|
|
Request *http.Request
|
|
|
|
|
OnConnect func(who *websocket.Conn)
|
|
|
|
|
OnMessage func(who *websocket.Conn, msg string)
|
|
|
|
|
OnDisconnect func(who *websocket.Conn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var upgrader = websocket.Upgrader{
|
|
|
|
|
ReadBufferSize: 1024,
|
|
|
|
|
WriteBufferSize: 1024,
|
|
|
|
|
CheckOrigin: func(r *http.Request) bool {
|
|
|
|
|
return strings.Contains(r.Host, "localhost")
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//DisplaySocket handles all socket calls from the display machine
|
|
|
|
|