Beispiel #1
0
func tableToMessage(L *lua.LState, t *lua.LTable) sarif.Message {
	msg := sarif.Message{}
	msg.Version = tableGetString(t, "sarif")
	msg.Id = tableGetString(t, "id")
	msg.Action = tableGetString(t, "action")
	msg.Source = tableGetString(t, "src")
	msg.Destination = tableGetString(t, "dest")
	msg.CorrId = tableGetString(t, "corr")
	msg.Text = tableGetString(t, "text")

	p := luareflect.DecodeToBasic(t.RawGetH(lua.LString("p")))
	msg.EncodePayload(p)
	return msg
}
Beispiel #2
0
func (cv *Conversation) SendToClient(msg sarif.Message) {
	// Save conversation.
	cv.LastTime = time.Now()
	cv.LastMessage = msg

	// Analyze message for possible user actions
	cv.LastMessageAction = Actionable{}
	msg.DecodePayload(&cv.LastMessageAction)

	msg = cv.service.AnnotateReply(msg)

	// Forward response to client.
	msg.Id = sarif.GenerateId()
	msg.Destination = cv.Device
	cv.service.Publish(msg)
}