How to Post Chat History After Subscribing to Channel

Options

Greetings.

When subscribing to a channel, you use an int to set how much history you want from 0 - 100.

I imagine that gets stored in the PublicChannels dictionary.

How do I get those string to then display in the chat room?

I think I'm having two difficulties.

One, I'm not sure I'm referencing the dictionary correctly. It is being created in ChatClient.cs, right?

I have a script with a class that creates a static instance of my chat client.

I then reference my chat client by doing something like myClass.Instance.chatClient

But, I'm not setting up the dictionary in myClass. That's being done automatically in the api in ChatClient.cs right? So how do I reference that dictionary in other scripts, and how to I get the chat entries to display in the chat room when player subscribes?

Best Answer

  • mrphilipjoel
    Answer ✓
    Options

    I got it figured out thanks to help from someone in a discord community I'm in. In a nutshell, I did something like below.

    foreach (ChatChannel msg in client.PublicChannels.Values)
    {
    	for (int i = 0; i < msg.Senders.Count; i++)
    	tmp.text += msg.Senders[i] + ": " + msg.Messages[i];
    }
    

Answers

  • mrphilipjoel
    Answer ✓
    Options

    I got it figured out thanks to help from someone in a discord community I'm in. In a nutshell, I did something like below.

    foreach (ChatChannel msg in client.PublicChannels.Values)
    {
    	for (int i = 0; i < msg.Senders.Count; i++)
    	tmp.text += msg.Senders[i] + ": " + msg.Messages[i];
    }