dennwc / dom

DOM library for Go and WASM
Apache License 2.0
487 stars 59 forks source link

GRPC over WebRTC using WASM #10

Open ghost opened 5 years ago

ghost commented 5 years ago

there is a pure webrtc golang impl here:https://github.com/pions/webrtc

SO i was thinking its maybe possible to do GRPC over Webrtc. This could then allow p2p style architecture. it woudl be usable for server to server and server to browser, Or server to desktop client. So sort of one network transport for everything and GRPC for everything.

what do you think ? I am not sure it will work but its a metetr of trying i suspect.

BTW was very easy to get going and everything works immediatly. I make it all into a Makefile so no reliance on bash files:

LIB=github.com/dennwc/dom
LIB_FSPATH=${GOPATH}/src/$(LIB)

WASM_FILES="$(GOROOT)/misc/wasm"

GRPC=${LIB_FSPATH}/examples/grpc-over-ws

dep:
    go get -u github.com/dennwc/dom
    go install github.com/dennwc/dom/cmd/wasm-server

open:
    code ${LIB_FSPATH}

##

run:
    cd ${GOPATH}/src/github.com/dennwc/dom && wasm-server

run-ex-grpc:
    cd $(GRPC) && GOOS=js GOARCH=wasm go build -o client.wasm ./client.go
    cd $(GRPC) && cp ${WASM_FILES}/wasm_exec.js ./
    cd $(GRPC) && go run ./server.go
dennwc commented 5 years ago

Yes, I have plans to finish the WebRTC for WASM as soon as synchronous callbacks CL is merged.

Similar to the WebSocket API in this project, I planned to expose a single API that will use the project you mentioned on the host, and JS implementation in the browser (using build tags).

So definitely worth exploring :)

ghost commented 5 years ago

wow thats an amazing co-incidence. Sort of on the same path !

Yep thats exactly the approch i was thinking with the golang webrtc on the server. For Fat Clients ( Desktop and Mobile), we can use webrtc golang there.

dtel commented 5 years ago

wow thats an amazing co-incidence. Sort of on the same path !

Yep thats exactly the approch i was thinking with the golang webrtc on the server. For Fat Clients ( Desktop and Mobile), we can use webrtc golang there.

Do you have a sample of using pion-webrtc on the server and grow on the client?

dennwc commented 5 years ago

I think it was nice as an experiment for this package, but pion-webrtc now supports wasm natively. They've done a great job, So I will probably remove the example completely, or will just leave a gRPC signaling and use their library.