mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2025-11-14 22:03:43 -08:00
Move project to gosrc.io/xmpp
The URL will be more permanent as this is a place we dedicate as short URL for our go projects.
This commit is contained in:
@@ -3,13 +3,13 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"fluux.io/xmpp"
|
||||
"gosrc.io/xmpp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
component := MyComponent{Name: "Test Component", Category: "gateway", Type: "service"}
|
||||
component.xmpp = &xmpp.Component{Host: "service.localhost", Secret: "mypass"}
|
||||
component.xmpp.Connect("localhost:8888")
|
||||
_ = component.xmpp.Connect("localhost:8888")
|
||||
|
||||
for {
|
||||
packet, err := component.xmpp.ReadPacket()
|
||||
@@ -39,7 +39,7 @@ func main() {
|
||||
Type: "cancel",
|
||||
}
|
||||
reply := p.MakeError(xError)
|
||||
component.xmpp.Send(&reply)
|
||||
_ = component.xmpp.Send(&reply)
|
||||
}
|
||||
|
||||
case xmpp.Message:
|
||||
@@ -83,7 +83,7 @@ func DiscoResult(c MyComponent, attrs xmpp.PacketAttrs, info *xmpp.DiscoInfo) {
|
||||
}
|
||||
iq.AddPayload(&payload)
|
||||
|
||||
c.xmpp.Send(iq)
|
||||
_ = c.xmpp.Send(iq)
|
||||
}
|
||||
|
||||
func DiscoItems(c MyComponent, attrs xmpp.PacketAttrs, items *xmpp.DiscoItems) {
|
||||
@@ -98,5 +98,5 @@ func DiscoItems(c MyComponent, attrs xmpp.PacketAttrs, items *xmpp.DiscoItems) {
|
||||
}
|
||||
}
|
||||
iq.AddPayload(&payload)
|
||||
c.xmpp.Send(iq)
|
||||
_ = c.xmpp.Send(iq)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"fluux.io/xmpp"
|
||||
"gosrc.io/xmpp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -37,11 +37,11 @@ func main() {
|
||||
for packet := range client.Recv() {
|
||||
switch packet := packet.(type) {
|
||||
case *xmpp.Message:
|
||||
fmt.Fprintf(os.Stdout, "Body = %s - from = %s\n", packet.Body, packet.From)
|
||||
_, _ = 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)
|
||||
_ = client.Send(reply)
|
||||
default:
|
||||
fmt.Fprintf(os.Stdout, "Ignoring packet: %T\n", packet)
|
||||
_, _ = fmt.Fprintf(os.Stdout, "Ignoring packet: %T\n", packet)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"fluux.io/xmpp"
|
||||
"fluux.io/xmpp/iot"
|
||||
"fluux.io/xmpp/pep"
|
||||
"github.com/processone/mpg123"
|
||||
"github.com/processone/soundcloud"
|
||||
"gosrc.io/xmpp"
|
||||
"gosrc.io/xmpp/iot"
|
||||
"gosrc.io/xmpp/pep"
|
||||
)
|
||||
|
||||
// Get the actual song Stream URL from SoundCloud website song URL and play it with mpg123 player.
|
||||
@@ -47,7 +47,7 @@ func main() {
|
||||
case xmpp.Presence:
|
||||
// Do nothing with received presence
|
||||
default:
|
||||
fmt.Fprintf(os.Stdout, "Ignoring packet: %T\n", packet)
|
||||
_, _ = fmt.Fprintf(os.Stdout, "Ignoring packet: %T\n", packet)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,17 +77,17 @@ 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)
|
||||
_ = client.Send(reply)
|
||||
// TODO add Soundclound artist / title retrieval
|
||||
sendUserTune(client, "Radiohead", "Spectre")
|
||||
default:
|
||||
fmt.Fprintf(os.Stdout, "Other IQ Payload: %T\n", packet.Payload)
|
||||
_, _ = fmt.Fprintf(os.Stdout, "Other IQ Payload: %T\n", packet.Payload)
|
||||
}
|
||||
}
|
||||
|
||||
func sendUserTune(client *xmpp.Client, artist string, title string) {
|
||||
tune := pep.Tune{Artist: artist, Title: title}
|
||||
client.SendRaw(tune.XMPPFormat())
|
||||
_ = client.SendRaw(tune.XMPPFormat())
|
||||
}
|
||||
|
||||
func playSCURL(p *mpg123.Player, rawURL string) {
|
||||
@@ -95,7 +95,7 @@ func playSCURL(p *mpg123.Player, rawURL string) {
|
||||
// TODO: Maybe we need to check the track itself to get the stream URL from reply ?
|
||||
url := soundcloud.FormatStreamURL(songID)
|
||||
|
||||
p.Play(url)
|
||||
_ = p.Play(url)
|
||||
}
|
||||
|
||||
func connectXmpp(jid string, password string, address string) (client *xmpp.Client, err error) {
|
||||
|
||||
Reference in New Issue
Block a user