Search code examples
c#winformssendbird

Get messages from BaseMessage


I have some problems with SendBird. As the documentation says:

Load previous messages After creating a query instance from the CreatePreviousMessageListQuery() method and using the Load() method which returns a list of message objects, you can retrieve a set number of previous messages in an open channel. With the returned list, you can display the past messages in your UI once they have loaded

With the following code:

mPrevMessageListQuery.Load(30, true, (List<BaseMessage> messages, SendBirdException e) => {
    if (e != null) {
        // Error.
        return;
    }
});

But, I cannot get the message from BaseMessage. I need to have UserMessage. How do I do that?


Solution

  • I got it.

        (UsrMSG((UserMessage)baseMessage));
    
        string UsrMSG(UserMessage message)
        {
            return message.Sender.Nickname + " ha detto: " + message.Message + "\n";
        }
    

    IT WAS SO SIMPLE