1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-20 03:17:04 +00:00

Update to version 11.0.1. Feature request implemented: https://github.com/kataras/iris/issues/1113

Former-commit-id: 0ce38dbacc2458fe327fa4401fdde1e69c8aacb0
This commit is contained in:
Gerasimos (Makis) Maropoulos
2018-10-28 01:19:22 +03:00
parent 8950ae7bb9
commit be32418bc1
16 changed files with 272 additions and 159 deletions

View File

@@ -26,8 +26,13 @@ func main() {
func setupWebsocket(app *iris.Application) {
// create our echo websocket server
ws := websocket.New(websocket.Config{
// These are low-level optionally fields,
// user/client can't see those values.
ReadBufferSize: 1024,
WriteBufferSize: 1024,
// only javascript client-side code has the same rule,
// which you serve using the ws.ClientSource (see below).
EvtMessagePrefix: []byte("my-custom-prefix:"),
})
ws.OnConnection(handleConnection)
@@ -38,7 +43,7 @@ func setupWebsocket(app *iris.Application) {
// serve the javascript built'n client-side library,
// see websockets.html script tags, this path is used.
app.Any("/iris-ws.js", func(ctx iris.Context) {
ctx.Write(websocket.ClientSource)
ctx.Write(ws.ClientSource)
})
}

View File

@@ -89,7 +89,7 @@ func SendMessage(serverID, to, method, message string) error {
func SendtBytes(serverID, to, method string, message []byte) error {
// look https://github.com/kataras/iris/blob/master/websocket/message.go , client.go and client.js
// to understand the buffer line:
buffer := []byte(fmt.Sprintf("iris-websocket-message:%v;0;%v;%v;", method, serverID, to))
buffer := []byte(fmt.Sprintf("%s%v;0;%v;%v;", websocket.DefaultEvtMessageKey, method, serverID, to))
buffer = append(buffer, message...)
_, err := WS.Write(buffer)
if err != nil {