You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
Mickael Remond 909cf753c9 Fix missing default channel creation 5 years ago
_examples Simplify component writing and make it similar to client 5 years ago
cmd/xmpp-check Move examples out of the cmd directory 5 years ago
.gitignore
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Dockerfile
LICENSE
README.md Update README.md 5 years ago
auth.go
backoff.go
backoff_test.go
check_cert.go
client.go Fix missing default channel creation 5 years ago
client_test.go Refactor ClientManager into a more generic StreamManager 5 years ago
codecov.yml
codeship-services.yml
codeship-steps.yml
codeship.env.encrypted
component.go Fix missing default channel creation 5 years ago
component_test.go Fix import and test 5 years ago
config.go Use StreamClient interface in StreamManager 5 years ago
conn_error.go
doc.go
go.mod Move examples out of the cmd directory 5 years ago
go.sum Move examples out of the cmd directory 5 years ago
iot_control.go
iot_control_test.go
iq.go
iq_test.go
jid.go Add helpers to access full / bare jid as string 5 years ago
jid_test.go Add helpers to access full / bare jid as string 5 years ago
message.go
message_test.go
msg_chat_markers.go
msg_chat_state.go
msg_oob.go
msg_receipts.go
msg_receipts_test.go
ns.go
packet.go
parser.go
pep.go
presence.go
presence_test.go
registry.go
registry_test.go
session.go
socket_proxy.go
starttls.go
stream.go Do not reconnect on "connection replaced" stream errors 5 years ago
stream_manager.go Use StreamClient interface in StreamManager 5 years ago
tcp_server_mock.go
test.sh
xmpp_test.go

README.md

Fluux XMPP

Codeship Status for FluuxIO/xmpp GoDoc GoReportCard codecov

Fluux XMPP is a Go XMPP library, focusing on simplicity, simple automation, and IoT.

The goal is to make simple to write simple adhoc XMPP clients:

  • For automation (like for example monitoring of an XMPP service),
  • For building connected "things" by plugging them on an XMPP server,
  • For writing simple chatbot to control a service or a thing.
  • For writing XMPP servers components.

The library is designed to have minimal dependencies. For now, the library does not depend on any other library.

Example

Here is a demo "echo" client:

package main

import (
	"fmt"
	"log"
	"os"

	"gosrc.io/xmpp"
)

func main() {
	config := xmpp.Config{
		Address:      "localhost:5222",
		Jid:          "test@localhost",
		Password:     "test",
		PacketLogger: os.Stdout,
		Insecure:     true,
	}

	client, err := xmpp.NewClient(config)
	if err != nil {
		log.Fatalf("%+v", err)
	}

	// If you pass the client to a connection manager, it will handle the reconnect policy
	// for you automatically.
	cm := xmpp.NewClientManager(client, nil)
	err = cm.Start()
	if err != nil {
		log.Fatal(err)
	}

	// Iterator to receive packets coming from our XMPP connection
	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)
			reply := xmpp.Message{PacketAttrs: xmpp.PacketAttrs{To: packet.From}, Body: packet.Body}
			_ = client.Send(reply)
		default:
			_, _ = fmt.Fprintf(os.Stdout, "Ignoring packet: %T\n", packet)
		}
	}
}

Documentation

Please, check GoDoc for more information: gosrc.io/xmpp