This commit is contained in:
Bruno Rybársky 2023-11-04 18:55:29 +01:00
parent 4df35bbec6
commit 8bfbb031a1
5 changed files with 18 additions and 17 deletions

8
.idea/.gitignore vendored

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

6
.idea/vcs.xml Normal file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

1
asedraw_client.lua Symbolic link

@ -0,0 +1 @@
/home/bruno/.config/aseprite/scripts/asedraw_client.lua

2
go.mod

@ -2,4 +2,4 @@ module asedraw
go 1.21
require github.com/gorilla/websocket v1.5.0
require github.com/gorilla/websocket v1.5.0 // indirect

18
main.go

@ -7,7 +7,7 @@ import (
"net/http"
)
var addr = flag.String("addr", "localhost:8080", "http service address")
var addr = flag.String("addr", "localhost:8797", "http service address")
var upgrader = websocket.Upgrader{} // use default options
@ -17,18 +17,20 @@ func echo(w http.ResponseWriter, r *http.Request) {
log.Print("upgrade:", err)
return
}
defer c.Close()
defer func(c *websocket.Conn) {
err := c.Close()
if err != nil {
log.Println("close: ", err)
return
}
}(c)
for {
mt, message, err := c.ReadMessage()
if err != nil {
log.Println("read:", err)
break
}
log.Printf("recv: %s", message)
err = c.WriteMessage(mt, message)
if err != nil {
log.Println("write:", err)
break
log.Println(err)
return
}
}
}