@@ -6,29 +6,26 @@ A Flutter plugin for XMPP (Extensible Messaging and Presence Protocol) communica
66
77## Features
88
9- - ✅ Cross-platform support (iOS and Android)
10- - ✅ Real-time messaging
11- - ✅ Presence management
12- - ✅ IQ (Info/Query) stanza support
13- - ✅ Connection state monitoring
14- - ✅ SSL/TLS encryption support
9+ - ✅ Minimal dependencies (xml(Dart), [ Smack] ( https://github.com/igniterealtime/Smack ) for Android, [ XMPPFramework] ( https://github.com/robbiehanson/XMPPFramework ) for iOS)
10+ - ✅ Pure XMPP interpreter.
11+ - ✅ Easy to customize.
1512- ✅ Stream-based architecture
16- - ✅ Comprehensive example app
1713
18- ## Platform Support
14+ ### Built-in Stanza Builders
1915
20- | Platform | Implementation |
21- | ----------| ----------------|
22- | iOS | XMPPFramework |
23- | Android | Smack Library |
16+ - Core XMPP Stanzas(IQ, Message, Presence).
17+ - [ XEP-0012 Last Activity] ( https://xmpp.org/extensions/xep-0012.html )
18+ - [ XEP-0085 Chat State Notifications] ( https://xmpp.org/extensions/xep-0085.html )
19+ - [ XEP-0184 Message Delivery Receipts] ( https://xmpp.org/extensions/xep-0184.html )
20+ - [ XEP-0313 Message Archive Management] ( https://xmpp.org/extensions/xep-0313.html )
2421
2522## Installation
2623
2724Add this to your package's ` pubspec.yaml ` file:
2825
2926``` yaml
3027dependencies :
31- fxmpp : ^1.0.0-alpha.2
28+ fxmpp : ^1.0.0
3229` ` `
3330
3431Then run:
@@ -114,7 +111,7 @@ try {
114111```
115112
116113### Sending Messages
117-
114+ #### Using built-in message builder
118115``` dart
119116final message = XmppMessage(
120117 id: DateTime.now().millisecondsSinceEpoch.toString(),
@@ -130,6 +127,20 @@ if (success) {
130127 print('Message sent successfully');
131128}
132129```
130+ #### Using XML builder
131+ ``` dart
132+ import 'package:xml/xml.dart';
133+
134+ final builder = XmlBuilder();
135+ builder.element('message', nest: () {
136+ builder.attribute('type', 'chat');
137+ builder.attribute('to', 'recipient@domain.com');
138+ builder.attribute('id', 'message_${DateTime.now().millisecondsSinceEpoch}');
139+ builder.element('body', nest: 'content');
140+ };
141+
142+ await _fxmpp.sendMessage(builder.buildDocument());
143+ ```
133144
134145### Sending IQ Stanzas
135146
@@ -176,101 +187,6 @@ if (success) {
176187await _fxmpp.disconnect();
177188```
178189
179- ## API Reference
180-
181- ### Classes
182-
183- #### ` Fxmpp `
184- Main class for XMPP operations.
185-
186- ** Methods:**
187- - ` initialize() ` - Initialize the plugin
188- - ` connect(XmppConnectionConfig config) ` - Connect to XMPP server
189- - ` disconnect() ` - Disconnect from server
190- - ` sendMessage(XmppMessage message) ` - Send a message
191- - ` sendPresence(XmppPresence presence) ` - Send presence update
192- - ` sendIq(XmlDocument iq) ` - Send an IQ stanza
193- - ` getConnectionState() ` - Get current connection state
194- - ` dispose() ` - Clean up resources
195-
196- ** Streams:**
197- - ` connectionStateStream ` - Stream of connection state changes
198- - ` messageStream ` - Stream of incoming messages
199- - ` presenceStream ` - Stream of presence updates
200- - ` iqStream ` - Stream of incoming IQ stanzas
201-
202- #### ` XmppConnectionConfig `
203- Configuration for XMPP connection.
204-
205- ** Properties:**
206- - ` host ` - XMPP server hostname
207- - ` port ` - Server port (default: 5222)
208- - ` username ` - Username for authentication
209- - ` password ` - Password for authentication
210- - ` domain ` - XMPP domain
211- - ` useSSL ` - Enable SSL/TLS (default: true)
212- - ` allowSelfSignedCertificates ` - Allow self-signed certificates (default: false)
213- - ` resource ` - Client resource identifier
214-
215- #### ` XmppMessage `
216- Represents an XMPP message.
217-
218- ** Properties:**
219- - ` id ` - Unique message identifier
220- - ` from ` - Sender JID
221- - ` to ` - Recipient JID
222- - ` body ` - Message content
223- - ` timestamp ` - Message timestamp
224- - ` type ` - Message type (chat, groupchat, etc.)
225- - ` extensions ` - Additional message data
226-
227- #### ` XmppPresence `
228- Represents XMPP presence information.
229-
230- ** Properties:**
231- - ` from ` - Sender JID
232- - ` to ` - Target JID (optional)
233- - ` type ` - Presence type
234- - ` show ` - Presence show value
235- - ` status ` - Status message
236- - ` priority ` - Presence priority
237- - ` timestamp ` - Presence timestamp
238-
239- ### Enums
240-
241- #### ` XmppConnectionState `
242- - ` disconnected ` - Not connected
243- - ` connecting ` - Connection in progress
244- - ` connected ` - Connected and authenticated
245- - ` disconnecting ` - Disconnection in progress
246- - ` error ` - Connection error
247- - ` authenticationFailed ` - Authentication failed
248- - ` connectionLost ` - Connection lost unexpectedly
249-
250- #### ` XmppMessageType `
251- - ` chat ` - One-to-one chat message
252- - ` groupchat ` - Group chat message
253- - ` headline ` - Headline message
254- - ` normal ` - Normal message
255- - ` error ` - Error message
256-
257- #### ` XmppPresenceType `
258- - ` available ` - Available presence
259- - ` unavailable ` - Unavailable presence
260- - ` subscribe ` - Subscription request
261- - ` subscribed ` - Subscription approved
262- - ` unsubscribe ` - Unsubscription request
263- - ` unsubscribed ` - Unsubscription approved
264- - ` probe ` - Presence probe
265- - ` error ` - Presence error
266-
267- #### ` XmppPresenceShow `
268- - ` online ` - Online/available
269- - ` away ` - Away
270- - ` chat ` - Available for chat
271- - ` dnd ` - Do not disturb
272- - ` xa ` - Extended away
273-
274190## Example App
275191
276192The package includes a comprehensive example app that demonstrates all features. To run the example:
@@ -308,33 +224,6 @@ Required permissions are automatically added to your app's `AndroidManifest.xml`
308224- Store credentials securely (consider using flutter_secure_storage)
309225- Validate all incoming messages and presence updates
310226
311- ## Troubleshooting
312-
313- ### Common Issues
314-
315- 1 . ** Connection fails with SSL errors**
316- - Ensure your XMPP server supports SSL/TLS
317- - Check if the server certificate is valid
318- - For testing only, you can set ` allowSelfSignedCertificates: true `
319-
320- 2 . ** Authentication fails**
321- - Verify username and password are correct
322- - Ensure the user account exists on the XMPP server
323- - Check if the domain is correct
324-
325- 3 . ** Messages not being received**
326- - Ensure you're listening to the ` messageStream `
327- - Check if the connection is in ` connected ` state
328- - Verify the recipient JID is correct
329-
330- 4 . ** iOS build issues**
331- - Run ` cd ios && pod install ` in your app directory
332- - Clean and rebuild your project
333-
334- 5 . ** Android build issues**
335- - Ensure your ` minSdkVersion ` is at least 16
336- - Clean and rebuild your project
337-
338227## Contributing
339228
340229Contributions are welcome! Please feel free to submit a Pull Request.
@@ -347,64 +236,14 @@ This project is licensed under the MIT License - see the LICENSE file for detail
347236
348237For issues and questions, please use the [ GitHub Issues] ( https://github.com/haithngn/fxmpp/issues ) page.
349238
350- ### Multi-User Chat (MUC) Support
351-
352- FXMPP supports Multi-User Chat (MUC) functionality for group conversations:
353-
354- ``` dart
355- // Join a MUC room
356- await _fxmpp.joinMucRoom(
357- roomJid: 'room@conference.example.com',
358- nickname: 'MyNickname',
359- password: 'optional-password', // optional
360- );
361-
362- // Send a message to the room
363- final mucMessage = Fxmpp.createMucMessage(
364- messageId: Fxmpp.generateId('muc'),
365- roomJid: 'room@conference.example.com',
366- fromJid: 'user@example.com',
367- message: 'Hello everyone!',
368- );
369- await _fxmpp.sendMucMessage(mucMessage);
370-
371- // Send a private message to a room participant
372- final privateMessage = Fxmpp.createMucPrivateMessage(
373- messageId: Fxmpp.generateId('muc_private'),
374- roomJid: 'room@conference.example.com',
375- nickname: 'TargetUser',
376- fromJid: 'user@example.com',
377- message: 'Private message',
378- );
379- await _fxmpp.sendMucPrivateMessage(privateMessage);
380-
381- // Leave the room
382- await _fxmpp.leaveMucRoom(
383- roomJid: 'room@conference.example.com',
384- reason: 'Goodbye!', // optional
385- );
386-
387- // Listen to MUC events
388- _fxmpp.mucRoomEventStream.listen((event) {
389- print('MUC room event: ${event.type}');
390- });
391-
392- _fxmpp.mucParticipantEventStream.listen((event) {
393- print('Participant event: ${event.type}');
394- });
395-
396- _fxmpp.mucMessageStream.listen((message) {
397- print('MUC message: ${message.body}');
398- });
399- ```
400-
401239## Changelog
240+ ### 1.0.0
241+ - Core XMPP Features.
242+ - MUC.
243+ - Stanza Builders: IQ, Message, Presence, XEP-0012, XEP-0085, XEP-0184, XEP-0313.
402244
403245### 1.0.0-alpha.2
404- - ** BREAKING** : Refactored MUC API for consistency with other stanza methods
405- - Added ` Fxmpp.createMucMessage() ` and ` Fxmpp.createMucPrivateMessage() ` utility methods
406- - Updated MUC methods to accept ` XmlDocument ` objects instead of primitive types
407- - Enhanced example app with updated MUC usage
246+ - ** BREAKING** : Support MUC.
408247
409248### 1.0.0-alpha
410249- Added IQ (Info/Query) stanza support
0 commit comments