예제 #1
0
func websocketHandler(writer http.ResponseWriter, request *http.Request, bus *EventBus.EventBus) {
	connection, err := websocketUpgrader.Upgrade(writer, request, nil)
	if err != nil {
		log.Fatal("Failed to get websocket upgrade")
		return
	}

	for {
		typeMessage, message, err := connection.ReadMessage()
		bus.Publish(lib.NEW_MESSAGE_EVENT, string(message[:]))

		device_header := request.Header[DEVICE_ID_HEADER]

		if len(device_header) > 0 && device_header[0] != "" {
			bus.Publish(lib.NEW_DEVICE_EVENT, device_header[0])
		}

		if err != nil {
			log.Fatal(err)
			break
		}

		connection.WriteMessage(typeMessage, message)
	}
}
예제 #2
0
파일: docker.go 프로젝트: mudler/artemide
// Process builds a list of packages from the boson file
func (d *Docker) Register(bus *evbus.EventBus, context *context.Context) { //returns args and volumes to mount

	client, _ := NewClient("unix:///var/run/docker.sock")

	bus.Subscribe("artemide:start", Start) //Subscribing to artemide:start, Hello will be called
	bus.Subscribe("artemide:source:docker", client.Unpack)

}
예제 #3
0
파일: script.go 프로젝트: mudler/artemide
// Process builds a list of packages from the boson file
func (s *Script) Register(bus *evbus.EventBus, context *context.Context) { //returns args and volumes to mount
	bus.Subscribe("artemide:start", Start)                                                  //Subscribing to artemide:start, Hello will be called
	bus.Subscribe("artemide:artifact:recipe:script:event:after_unpack", afterUnpackHandler) //Subscribing to artemide:artifact:recipe:script:event:after_unpack, the After unpack handler
}