Add HTTP Server Support
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by tracing the existing socket server entry point in the LiveSplit.Server component; the issue does not name a file or test. Add an HTTP endpoint that forwards the requested command to the socket server and supports browser CORS, then verify that browser-based requests can trigger commands without requiring a separate proxy.
Written by the indexing model from the issue text.
Description
TL; DR: Please consider adding a HTTP server (that is CORS aware) in addition to the socket server.
I was trying to use LiveSplit with a web browser based game via a Web Extension. Extensions can't open socket connections. Chrome apps can, but a browser app didn't seem appropriate for my project. So I ended up writing a thin Go wrapper to proxy HTTP to Socket, that ignores CORS, and ignores socket responses.
package main
import (
"fmt"
"log"
"net"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
conn, _ := net.Dial("tcp", "127.0.0.1:16834")
fmt.Fprintf(conn, "%s\r\n", r.URL.Path[1:])
fmt.Fprintf(w, "")
}
func main() {
http.HandleFunc("/", handler)
log.Fatal(http.ListenAndServe(":16835", nil))
}
From my extension, I'd call it like this:
sendCmd = (cmd) ->
request = new XMLHttpRequest
request.open "POST", "http://127.0.0.1.nip.io:16835/#{cmd}", true
do request.send
sendCmd 'startorsplit'
Whatever was sent as the PATH of the URL is used as the socket command. Using form data, etc, would be fine, too. This solution worked quite well for my use case. I had to grant permission to the domain in my extension, but if the proxy served a CORS header like Access-Control-Allow-Origin: * it should just work without a domain permission. If a simple HTTP server was setup as part of this live split extension, then it would be really easy to build LiveSplit integrations for any browser based web game.
- Dominant language
- C#
- Stars
- 52
- Forks
- 33
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from LiveSplit/LiveSplit.Server
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
LiveSplit/LiveSplit.Server#36 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
LiveSplit/LiveSplit.Server#29 · 7 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in LiveSplit/LiveSplit.Server
Similar issues
-
priority-0
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
StackExchange/StackExchange.Redis#3249 ·
-
[Feat] 조합 영역 구분선 개선 Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100