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) } }
// 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) }
// 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 }