Beispiel #1
0
// TestNewEventCreation - Just basic test to ensure that logging loger returns right
// logging context. In addition to that we'll check few additional methods such
// as context
func TestNewEventCreation(t *testing.T) {

	msg := TestMessage{
		false, byte(0), true, "powerunit-io-bridge", 01, []byte(TestMsgBedroomDhtSensor),
	}

	Convey("Test If Proper Type", t, func() {
		e, err := events.NewEvent(&msg)
		So(err, ShouldHaveSameTypeAs, nil)
		So(e, ShouldHaveSameTypeAs, events.Event{})
	})

}
Beispiel #2
0
// BrokerHandler -
func (c *Connection) BrokerHandler(client *MQTT.Client, msg MQTT.Message) {
	c.Info(
		"Received new mqtt (worker: %s) - (message: %s) for (topic: %s). Building event now ...",
		c.Name(), msg.Payload(), msg.Topic(),
	)

	event, err := events.NewEvent(msg)

	if err != nil {
		c.Error("Could not handle received event due to (err: %s)", err)
		return
	}

	c.Info("Event successfully created (data: %v)", event)
	c.events <- event
}