Implements send / send raw

This commit is contained in:
Mickael Remond
2018-01-26 09:55:39 +01:00
parent 2cd8eed765
commit ad6e09a0f6
4 changed files with 39 additions and 8 deletions

View File

@@ -13,7 +13,13 @@ import (
)
func main() {
options := xmpp.Options{Address: "localhost:5222", Jid: "test@localhost", Password: "test", PacketLogger: os.Stdout}
options := xmpp.Options{
Address: "localhost:5222",
Jid: "test@localhost",
Password: "test",
PacketLogger: os.Stdout,
Insecure: true,
}
var client *xmpp.Client
var err error
@@ -34,7 +40,7 @@ func main() {
case *xmpp.Message:
fmt.Fprintf(os.Stdout, "Body = %s - from = %s\n", packet.Body, packet.From)
reply := xmpp.Message{PacketAttrs: xmpp.PacketAttrs{To: packet.From}, Body: packet.Body}
client.Send(reply.XMPPFormat())
client.Send(reply)
default:
fmt.Fprintf(os.Stdout, "Ignoring packet: %T\n", packet)
}

View File

@@ -77,7 +77,7 @@ func processIq(client *xmpp.Client, p *mpg123.Player, packet *xmpp.IQ) {
playSCURL(p, url)
setResponse := new(iot.ControlSetResponse)
reply := xmpp.IQ{PacketAttrs: xmpp.PacketAttrs{To: packet.From, Type: "result", Id: packet.Id}, Payload: []xmpp.IQPayload{setResponse}}
client.Send(reply.XMPPFormat())
client.SendRaw(reply.XMPPFormat())
// TODO add Soundclound artist / title retrieval
sendUserTune(client, "Radiohead", "Spectre")
default:
@@ -87,7 +87,7 @@ func processIq(client *xmpp.Client, p *mpg123.Player, packet *xmpp.IQ) {
func sendUserTune(client *xmpp.Client, artist string, title string) {
tune := pep.Tune{Artist: artist, Title: title}
client.Send(tune.XMPPFormat())
client.SendRaw(tune.XMPPFormat())
}
func playSCURL(p *mpg123.Player, rawURL string) {