- Home /
Question by
Chainksain · Dec 21, 2020 at 05:51 AM ·
photonchat
Problems with Photon Chat
I'm trying to implement a chat system in my game using photon chat, but simply it doesnt work, idk why, theres no erro messages, theres no warnings there's no logs, it simply dont work, if i use Debug.Log to show message it simply show nothing (the log message shows with empy string). The prefab even is instantiated, here's my code:
public void OnGetMessages(string channelName, string[] senders, object[] messages)
{
/* All public messages are automatically cached in `Dictionary<string, ChatChannel> PublicChannels`.
* So you don't have to keep track of them.
* The channel name is the key for `PublicChannels`.
* In very long or active conversations, you might want to trim each channels history.
*/
foreach (var channel in chatClient.PublicChannels)
{
if(channelName == channel.Key)
{
for (int i = 0; i < senders.Length; i++)
{
GameController.networkController.authManager.database.GetReference("users").Child(senders[i]).GetValueAsync().ContinueWith(t =>
{
if (t.IsFaulted)
Debug.LogError(t.Exception);
else if (t.IsCompleted)
{
DataSnapshot snapshot = t.Result;
if (snapshot.Exists)
Instantiate(TextPrefab, chatContent).GetComponent<TextMeshProUGUI>().text =
string.Format("{0} : {1}", snapshot.Child("DisplayName").Value, messages[i]);
}
});
}
break;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Player sometimes gets other Players name on ChatBox? 0 Answers
Photon MMO chat 0 Answers
Photon Chat Change Order 0 Answers