mirror of
				https://github.com/FluuxIO/go-xmpp.git
				synced 2025-10-31 00:13:44 -07:00 
			
		
		
		
	Add Client Manager to monitor connection state and trigger reconnect (#39)
- Support for exponential backoff on reconnect to be gentle on the server. - Clean up client by moving metrics and retry strategy to the connection manager. - Update echo_client to use client manager - Fix echo client XMPP message matching Fixes #21 Improvements for #8
This commit is contained in:
		| @@ -26,17 +26,14 @@ func main() { | ||||
| 		log.Fatal("Error: ", err) | ||||
| 	} | ||||
|  | ||||
| 	session, err := client.Connect() | ||||
| 	if err != nil { | ||||
| 		log.Fatal("Error: ", err) | ||||
| 	} | ||||
|  | ||||
| 	fmt.Println("Stream opened, we have streamID = ", session.StreamId) | ||||
| 	cm := xmpp.NewClientManager(client, nil) | ||||
| 	cm.Start() | ||||
| 	// connection can be stopped with cm.Stop(). | ||||
|  | ||||
| 	// Iterator to receive packets coming from our XMPP connection | ||||
| 	for packet := range client.Recv() { | ||||
| 		switch packet := packet.(type) { | ||||
| 		case *xmpp.Message: | ||||
| 		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) | ||||
| @@ -47,6 +44,4 @@ func main() { | ||||
| } | ||||
|  | ||||
| // TODO create default command line client to send message or to send an arbitrary XMPP sequence from a file, | ||||
| // (using templates ?) | ||||
|  | ||||
| // TODO: autoreconnect when connection is lost | ||||
| //   (using templates ?) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Mickaël Rémond
					Mickaël Rémond