Giter VIP home page Giter VIP logo

webtransport-serverless-demo's Introduction

WebTransport Serverless Demo

Webtransport serverless yomo

  1. Open https://webtransport.day/serverless with Chrome latest version (at least verion 98).
  2. Click go to allegro cloud,reirect to https://allegrocloud.io console.
  3. Click Sign Up -> Continue With GitHub to login with your Github Account.
  4. Click + New Project to create a new Geo-distributed Service.
  5. In the detail page of project, you will get Zipper Address, App Key and App Secret.
  6. Back to https://webtransport.day/serverless and paste values.
  7. Click Connect to create the webtransport connection.
  8. Type hello world below Send data over WebTransport.
  9. Click Send data, will see Sent datagram: hello world in Event Log, but there are no response.
  10. Clone this repo gh repo clone fanweixiao/webtransport-serverless-demo and open it in your favorite terminal.
  11. Install YoMo CLI: $ curl -fsSL "https://bina.egoist.sh/yomorun/cli?name=yomo" | sh
  12. Run yomo run -u "edge.yomo.dev:9000" -d "app-key-secret:${YOUR_APP_KEY}|${YOUR_APP_SECRET}" -n testwt ./func.go
  13. Back to Chrome, Click Send data, will see the response Datagram received: HELLO WORLD in Event Log.

webtransport-serverless-demo's People

Contributors

fanweixiao avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

0thc

webtransport-serverless-demo's Issues

https://webtransport.day echo server down?

I'm not sure if this is the right place to open this issue, but there's no repo link on https://webtransport.day so I'm guessing here, my apologies if I've got it wrong.

The echo server at https://webtransport.day appears to be down because all connection attempts fail at the handshake step.

Could someone please give it a kick? I'm investigating a bug with WebTransport bidi streams and it'd be really useful to be able to share a simple repro using the echo server.

yomo build err

When trying to build


import (
	"encoding/json"
	"fmt"
	"log"
	"strings"

	"github.com/yomorun/yomo/core/frame"
	//"github.com/yomorun/yomo/serverless"
)

type Message struct {
	Meta *MessageMeta `json:"meta"`
	Data []byte       `json:"data"`
}

type MessageMeta struct {
	Mode     string `json:"mode"` // datagram | stream
	StreamID int64  `json:"stream_id"`
}

// Init will initialize the stream function
func Init() error {
	fmt.Println("sfn init")
	return nil
}

// Handler will handle the raw data
func Handler(tag frame.Tag, request []byte) (byte, []byte) {
	var err error
	defer func() {
		if err != nil {
			log.Println(err)
		}
	}()

	var message Message
	if err := json.Unmarshal(request, &message); err != nil {
		return 0, nil
	}

	// Convert to uppercase
	log.Printf("[mode=%s][streamID=%d] received data, len=%d, data:%+v", message.Meta.Mode, message.Meta.StreamID, len(message.Data), message.Data)
	message.Data = []byte(strings.ToUpper(string(message.Data)))

	// Send data back to webtransport.day client.
	response, err := json.Marshal(message)
	if err != nil {
		log.Println(err)
		return 0, nil
	}

	return 0x31, response
}

func DataTags() []uint32 {
	return []uint32{0x33}
}

aleksandarsvinarov@Aleksandars-MacBook-Pro test % yomo build app.go
ℹ️ YoMo Stream Function file: app.go
⌛ YoMo Stream Function building...
❌ Build: failure, tinygo # command-line-arguments
../../../../../../../var/folders/y_/9n1x7hx16k3fsgf3b98fr5l00000gn/T/yomo_3553533757/app.go:65:18: cannot use Handler (value of type func(tag uint32, request []byte) (byte, []byte)) as func(ctx serverless.Context) value in assignment

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.