Skip to content
This repository has been archived by the owner on Aug 1, 2019. It is now read-only.

Extended README by adding "how to integrate with a network service" instructions #114

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

dodikk
Copy link

@dodikk dodikk commented Apr 1, 2017

Fixing #95

Topics Covered :

  • cocoapods badge added
  • foreword and chapter structure
  • realtime message sending
  • realtime message receiving
  • handling history (a simple approach)

//
_ = super.sendText($0.text, isIncomingMessage: $0.isIncoming)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry it took me a while to get around to explaining this. It's the perfect use case for head async prefetching.

To use this, you need to set doesBatchFetch: Bool = true on NMessenger. NMessengerViewController should implement the NMessengerDelegate. You will need to add the optionalfunc batchFetchContent() to the ViewController. This function will be called when you start to scroll up in the chat history. Ideally, the client should fetch history rather than the server pushing it to the client. The following code describes this functionality:

func batchFetchContent() { //called when you begin to scroll up and NMessenger decides that messages could be prefetched
  getMessages { (messages) -> Void in  //call your server to get messages
    endBatchFetchWithMessages(messages: messages) //adds messages to the beginning of the NMessenger
  }
}

Calling endBatchFetchWithMessagesclears the lock on the prefetch mechanism so that it can be called again when you continue to scroll up.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atainter , i am sorry but i am still unsure how to extend my PR properly. I would be grateful if you elaborated on adding the missing parts and posted the result to a readme (or a wiki page or some other documentation piece for this library).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some topics to cover:

  1. Add some details of the prefetching usage to the readme.
  2. How to open the chat with some history pre-populated. Meaning, what to do after an async service call from viewWillAppear Notifies the completion.
  3. How to handle the "some past offline messages have been pushed by the server" situation you've described in your comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as How to handle the "some past offline messages have been pushed by the server" situation you've described in your comment. goes, NMessenger is not really setup for that. The client is meant to query for past offline message. Currently, you cannot add messages out of order because of the way referencing was built. I would build your server to send history in order so that you can use the batchFetchContent() callback.

I created a docs-wip branch. Can you resubmit the PR to merge with that branch? I'll help edit the docs to further explain 1 and 2.

@dodikk
Copy link
Author

dodikk commented Apr 4, 2017

I created a docs-wip branch. Can you resubmit the PR to merge with that branch? I'll help edit the docs to further explain 1 and 2.

Done : #116

@dodikk
Copy link
Author

dodikk commented Apr 4, 2017

A bit more samples/snippets (just in case) documented
#117

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants