piyush77 / XMPP-DOC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XMPPManager

Info

It is an ordinary XMPP client for iOS with Files.

What can this app do:

Group chat

  • Authentication with server
  • Create and join group with invitation request
  • Text chat to group
  • Message archiving (history)
  • Push notifications
  • Block user in group
  • Kick user from group
  • Exchange group owner authority
  • Remove group owner
  • Get members of groups
  • GetOwnerofGroup
  • Unscribes from Room
  • Get Room Info
  • Get List of rooms
  • Store and get User avtar and username

TODO

Planned Features For Group chat

  • Update Group avtar image
  • image sharing with preview
  • video sharing with preview
  • audio sharing with player
  • File transter
  • Typing indicator
  • Read unread badge count

One to one chat

  • Authentication with server
  • Text chat
  • Message archiving (history)
  • Store and get User avtar and username
  • Sharing media - image, video and audio
  • File transter
  • Read receipt
  • Typing Indicator
  • Read unread badge count

Usage example

For Message Chat UI we used following Library

https://github.com/MessageKit/MessageKit

Authentication

XMPPManager.shared.delegate = self
XMPPManager.shared.authenticateWith(userName: "<XMPP_USER_ID>", password: "<XMPP_Password>")
XMPPManager.shared.didAuthenticate = {  isAuth in
   // Authentication response
}

Authentication

XMPPManagerProtocol
/// Triggered when xmpp stream connects.
///
func xmppStreamDidConnect()

/// Triggered when xmpp stream Did not connects.
///
func xmppStreamDidNotConnect()

/// Triggered when xmpp stream Disconnect.
///
func xmppStreamDidDisconnect()

/// Triggered when xmpp stream did timeout.
///
func xmppStreamDidTimeout()

/// Triggered when xmpp stream connects.
///
func xmppUserDidRegister()

/// Triggered when xmpp user fails to register.
///
func xmppUserDidNotRegister()

/// Triggered when xmpp user already registered.
func xmppUserAlreadyRegistered()

/// Triggered when xmpp user did authenticate.
///
func xmppUserDidAuthenticate()

/// Triggered when xmpp user did fail to authenticate.
///
func xmppUserDidNotAuthenticate()

/// Triggered when xmpp user status like oneline or offline.
///
func xmppUserStatus(user:String, status: BuddyStatus)

/// Triggered when xmpp did receive message.
///
func xmppDidReceiveMessage(message: USMessage)

Join or Create Room

XMPPRoomManager.shared.delegate = self
XMPPRoomManager.shared.joinRoom(roomJID: "<RoomJID>:, shouldGetHistory: true)

Send Message to Room

XMPPRoomManager.shared.send(message: text, to: "<roomJID>")

XMPPRoomManager Protocol

/// Triggered when xmpp did creat room.
///
func roomDidCreate()

/// Triggered when xmpp did Not creatRoom.
///
func didNotCreatRoom()

/// Triggered when room did  Configure.
///
func roomDidConfigureWith(roomID: String)

/// Triggered when user did Join Chat Room.
///
func didJoinChatRoomWith(roomID: String)

/// Triggered when user Accept request to Join Chat Room.
///
func memberDidJoinChatRoomWith()

/// Triggered when xmpp did receive message.
///
func didReceiveGroupMessage(message: USMessage)

Retrive Message History

history.addAttribute(withName: "since", stringValue: "1970-01-01T00:00:00Z") // User Requests All History
history.addAttribute(withName: "maxstanzas", stringValue: "1000") // User Requests Limit on Number of Messages in History
history.addAttribute(withName: "seconds", stringValue: "604800") // User Requests History for Last 7 days (seconds)
history.addAttribute(withName: "maxchars", stringValue: "0") // User Requests no history

Leave From Room

XMPPRoomManager.shared.xmppRoom.deactivate()
XMPPRoomManager.shared.xmppRoom.leave()

Disconnect Stream

XMPPManager.shared.disconnectXMPP()

About