Open dodikk opened 7 years ago
So, in order to send
a message, I have to make an override
:
// Declared in NMessengerViewController
//
override func sendText(_ text: String, isIncomingMessage:Bool) -> GeneralMessengerCell
{
let shouldSendToServer = !isIncomingMessage
if (shouldSendToServer)
{
// trigger network service
self.controller?.sendMessageAsync(text)
}
// otherwise - just render
return super.sendText(text, isIncomingMessage: isIncomingMessage)
}
Here is a take on error handling https://github.com/eBay/NMessenger/issues/25 Haven't tried it yet.
Receiving a message from the network service :
func chatDidReceiveMessages(_ messageList: ChatMessageList)
{
messageList.forEach
{
_ = self.sendText($0.text, isIncomingMessage: true)
}
}
I'm going to prepare a PR with readme
changes these days.
Thank you. I'll merge it in.
@atainter , I still have some difficulties with the understanding of "async head prefetching". I'd like to cover this topic in my PR as well. Could you explain in a bit more details, please? https://github.com/eBay/NMessenger/issues/97
As a rule, a chat application involves the following actions :
I have not figured out yet how to insert the bubbles for past messages to the top. Is "clearALLMessages()" and invoke "send___()" in a loop the only way for doing that? Is it a correct approach? Does NMessenger take care of the unintended "blinking" animation in such case?
My use case might even require inserting messages in the middle
of the conversation. Several thousand users per room (text conference) are expected.
So the idea is
Showing "latest N" messages as a new batch arrives and ignore the rest of the batch until the user scrolls up to see those.
Not sure how to implement that with NMessenger although it seems promising as it's built on top of AsyncDisplayKit.
@atainter , the README has been updated. https://github.com/eBay/NMessenger/pull/114 Not sure how to complete history related part: I don't like "purge everything" approach but I have not figured out the alternative.
P.S. sorry for such a delay making this PR.
Not sure how to complete history related part: I don't like "purge everything" approach but I have not figured out the alternative.
Actually, it's possible to make a custom insertion using the method below.
super.messengerView.addMessages(_,
atIndex:,
scrollToMessage:,
animation:,
completion:)
The method is used as a part of batch fetching implementation. https://github.com/eBay/NMessenger/blob/master/nMessenger/Source/Messenger/Components/NMessenger.swift#L203
@dodikk @atainter is it possible to send a typed message withOUT rendering on the ui?.. IE I just want to update the DB when a message is typed
override func sendText(_ text: String, isIncomingMessage:Bool) -> GeneralMessengerCell
{
let shouldSendToServer = !isIncomingMessage
if (shouldSendToServer)
{
// trigger network service
self.controller?.sendMessageAsync(text)
}
// otherwise - just render (To NOT DO This part)
return super.sendText(text, isIncomingMessage: isIncomingMessage)
}
is it possible to send a typed message withOUT rendering on the ui
Override the function below and do not call super
.
open override func onSendButtonTapped(havingText currentText: String)
Still, It might be a good idea to render the message before receiving an xmpp delivery confirmation to provide the user with some feedback.
As a new user, I can't figure out which method is responsible for handling user's input. It's not quite clear where to put the networking code invocation. Is it
sendText
? Oh, I'm subclassing theNMessengerViewController
.Ideally, I'd like to have the following topics documented :
send message to network
action ?message received from network
event properly?Head Prefetching
?