Skip to content
This repository was archived by the owner on May 24, 2023. It is now read-only.
This repository was archived by the owner on May 24, 2023. It is now read-only.

Example to implement json rpc 2 with net/rpc/jsonrpc #141

@saul-data

Description

@saul-data

I tried to adapt this example for go fiber v2 websockets
https://gist.github.com/mowings/dad4917b6fc21e6e5ffe2da3b16e7ef9

func main() {
	rpc.Register(new(Arith))

	http.Handle("/ws", websocket.Handler(serve))
	http.ListenAndServe("localhost:7000", nil)
}

func serve(ws *websocket.Conn) {
	log.Printf("Handler starting")
	jsonrpc.ServeConn(ws)
	log.Printf("Handler exiting")
}

I get this error:
cannot use c (variable of type *"github.com/gofiber/websocket/v2".Conn) as io.ReadWriteCloser value in argument to jsonrpc.NewClient: *"github.com/gofiber/websocket/v2".Conn does not implement io.ReadWriteCloser (missing method Read)

Is there a way to adapt golang.org/x/net/websocket to be used with go fiber websockets?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions