Websocket client sample integration (go) for FairOS.

fairos-websocket-client

FairOS websocket clients should be an extension on the FairOS OpenAPI specification, with introduction of events for seamless communication over a websocket connection.

Events

All the events correspond to similar REST api calls as in the OpenAPI Specification.

Available events

    "/user/signup"
    "/user/login"
    "/user/import"
    "/user/present"
    "/user/isloggedin"
    "/user/logout"
    "/user/export"
    "/user/delete"
    "/user/stat"
    "/pod/new"
    "/pod/open"
    "/pod/close"
    "/pod/sync"
    "/pod/delete"
    "/pod/ls"
    "/pod/stat"
    "/pod/share"
    "/pod/receive"
    "/pod/receiveinfo"
    "/dir/present"
    "/dir/mkdir"
    "/dir/rmdir"
    "/dir/ls"
    "/dir/stat"
    "/file/download"
    "/file/upload"
    "/file/share"
    "/file/receive"
    "/file/receiveinfo"
    "/file/delete"
    "/file/stat"
    "/kv/new"
    "/kv/ls"
    "/kv/open"
    "/kv/delete"
    "/kv/count"
    "/kv/entry/put"
    "/kv/entry/get"
    "/kv/entry/del"
    "/kv/loadcsv"
    "/kv/seek"
    "/kv/seek/next"
    "/doc/new"
    "/doc/ls"
    "/doc/open"
    "/doc/count"
    "/doc/delete"
    "/doc/find"
    "/doc/entry/put"
    "/doc/entry/get"
    "/doc/entry/del"
    "/doc/loadjson"
    "/doc/indexjson"

Connection

To make a successful websocket connection we need to dial the following

    var base = localhost:9090
    
    // replace base with a running fairOS server api endpoint
    var uri = ws://base/ws/v1/

Requests & Responses

FairOS websocket communication relies on request-response model. After a successful connection is made, we can send an event request with their required payload and expect an event response with associated payload.

NOTE: we can relate each event with a REST api and refer to that request and response body from the OpenAPI Specification

Here is how an event request body should look like

{
    "event": "/user/signup"
    "params": {
        "user_name": "brand_new_user",
        "password": "VerySecretPassword"
    }
}

For each event request, server will send the response associated with the request along with the event and status_code. The status_code will indicate the same as if it were a REST api call.

For the above event request we will get the following response if the is no error.

{
    "event":"/user/signup",
    "code":201,
    "params":{
        "address":"0x268d2Ec795ea7677981135DE235e49FfD5634C46",
        "mnemonic":"network purse sudden loop forget accuse autumn win weird glow father unique"
    }
}

File upload

Currently, we have a total of three events that deals with file upload.

    "/file/upload"
    "/doc/loadjson"
    "/kv/loadcsv"

To upload a file via a websocket connection we need to first request for the event then send the file in BinaryMessage in subsequent requests.

NOTE: Please refer to the client for implementation more details.

File download

Event /file/download deals with file download. Server will first send event response for /event/download then send the file content in BinaryMessage in subsequent responses.

NOTE: Please refer to the client for implementation more details.

Similar Resources

Chat bots (& more) for Zoom by figuring out their websocket protocol

Chat bots (& more) for Zoom by figuring out their websocket protocol

zoomer - Bot library for Zoom meetings Good bot support is part of what makes Discord so nice to use. Unfortunately, the official Zoom API is basicall

Dec 14, 2022

Tiny WebSocket library for Go.

RFC6455 WebSocket implementation in Go.

Dec 28, 2022

Simple example for using Turbos Streams in Go with the Gorilla WebSocket toolkit.

Go Example for TurboStreams over WebSockets Simple example for using Turbos Streams in Go with the Gorilla WebSocket toolkit.

Dec 22, 2022

Minimal and idiomatic WebSocket library for Go

websocket websocket is a minimal and idiomatic WebSocket library for Go. Install go get nhooyr.io/websocket Highlights Minimal and idiomatic API First

Dec 31, 2022

:notes: Minimalist websocket framework for Go

:notes: Minimalist websocket framework for Go

melody 🎶 Minimalist websocket framework for Go. Melody is websocket framework based on github.com/gorilla/websocket that abstracts away the tedious p

Dec 23, 2022

A modern, fast and scalable websocket framework with elegant API written in Go

A modern, fast and scalable websocket framework with elegant API written in Go

About neffos Neffos is a cross-platform real-time framework with expressive, elegant API written in Go. Neffos takes the pain out of development by ea

Dec 29, 2022

Terminal on browser via websocket

Terminal on browser via websocket. Supportted OS Linux Mac

Dec 27, 2022

run shell scripts by websocket with go lauguage

run shell scripts by websocket with go lauguage

go_shell_socket run shell scripts by websocket with go lauguage Usage pull project get gin and websocket with go get config config.json file build it

Mar 9, 2022

simpleChatInGo - This is a simple chat that i made for fun asnd learn more about websocket

simpleChatInGo - This is a simple chat that i made for fun asnd learn more about websocket

simpleChatInGo This is a simple chat that i made for fun asnd learn more about websocket deploy For deploy this you only need to run the command : $ d

Sep 21, 2022
Encrypted-websocket-chat - Encrypted websocket chat using golang

Encrypted websocket chat First version written in python This version should be

Sep 15, 2022
Websocket-chat - A simple websocket chat application
Websocket-chat - A simple websocket chat application

WebSocket Chat App This is a simple chat app based on websockets. It allows user

Jan 25, 2022
WebSocket Command Line Client written in Go

ws-cli WebSocket Command Line Client written in Go Installation go get github.com/kseo/ws-cli Usage $ ws-cli -url ws://echo.websocket.org connected (

Nov 12, 2021
A tiny command line websocket client written in Go

wsc A simplistic tool for sending and receiving websocket messages from a command line. Mainly useful to test websocket servers. Getting started: $ go

Jan 12, 2022
BrisGolang is a Go implementation of the game of briscola using the WebSocket protocol for client/server communication.

BrisGolang BrisGolang is a Go implementation of the game of briscola using the WebSocket protocol for client/server communication. Usage You can play

Nov 1, 2021
API that upgrades connection to use websocket. Contains server and client and testing how they communicate

Websocket Test API How to execute First run server using: make run-server. Then run many client instances with: make run-client. Then start typing in

Dec 25, 2021
Client Implementation of eosio state-history websocket.

Client Implementation of eosio state-history websocket.

Dec 6, 2022
A fast, well-tested and widely used WebSocket implementation for Go.

Gorilla WebSocket Gorilla WebSocket is a Go implementation of the WebSocket protocol. Documentation API Reference Chat example Command example Client

Jan 2, 2023
Turn any program that uses STDIN/STDOUT into a WebSocket server. Like inetd, but for WebSockets.

websocketd websocketd is a small command-line tool that will wrap an existing command-line interface program, and allow it to be accessed via a WebSoc

Dec 31, 2022
proxy your traffic through CDN using websocket

go-cdn2proxy proxy your traffic through CDN using websocket what does it do example server client thanks what does it do you can use this as a library

Dec 7, 2022