示例#1
0
文件: main.go 项目: conas/tno2
//Basic low level wotServer setup
func main() {
	//WoT server defines implements interaction with device
	wotServer := server.CreateFromDescriptionUri(model)
	setupWotServer(wotServer)

	//Frontend is transport implementation
	feCfg := col.AsMap([]*col.KeyValue{col.KV("port", 8080)})
	fe := frontend.NewHTTP(feCfg)
	fe.Bind("/01-basic-example", wotServer)
	fe.Start()
}
示例#2
0
文件: platform.go 项目: conas/tno2
func (p *Platform) AddWotServer(id, wotDescURI, ctxPath, beEncID, beID string, feIDs []string) {
	wotServer := server.CreateFromDescriptionUri(wotDescURI)
	p.wots[id] = wotServer
	be, _ := p.backends[beID]
	encoder, error := backend.Encoders.Get(beEncID)

	if error != nil {
		panic(error)
	}

	be.Bind(wotServer, ctxPath, encoder)

	for _, feId := range feIDs {
		frontend, _ := p.frontends[feId]
		frontend.Bind(ctxPath, wotServer)
	}
}