ChatGui.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. // --------------------------------------------------------------------------------------------------------------------
  2. // <copyright company="Exit Games GmbH"/>
  3. // <summary>Demo code for Photon Chat in Unity.</summary>
  4. // <author>developer@exitgames.com</author>
  5. // --------------------------------------------------------------------------------------------------------------------
  6. using System;
  7. using System.Collections.Generic;
  8. using UnityEngine;
  9. using UnityEngine.UI;
  10. using Photon.Chat;
  11. using Photon.Realtime;
  12. using AuthenticationValues = Photon.Chat.AuthenticationValues;
  13. #if PHOTON_UNITY_NETWORKING
  14. using Photon.Pun;
  15. #endif
  16. namespace Photon.Chat.Demo
  17. {
  18. /// <summary>
  19. /// This simple Chat UI demonstrate basics usages of the Chat Api
  20. /// </summary>
  21. /// <remarks>
  22. /// The ChatClient basically lets you create any number of channels.
  23. ///
  24. /// some friends are already set in the Chat demo "DemoChat-Scene", 'Joe', 'Jane' and 'Bob', simply log with them so that you can see the status changes in the Interface
  25. ///
  26. /// Workflow:
  27. /// Create ChatClient, Connect to a server with your AppID, Authenticate the user (apply a unique name,)
  28. /// and subscribe to some channels.
  29. /// Subscribe a channel before you publish to that channel!
  30. ///
  31. ///
  32. /// Note:
  33. /// Don't forget to call ChatClient.Service() on Update to keep the Chatclient operational.
  34. /// </remarks>
  35. public class ChatGui : MonoBehaviour, IChatClientListener
  36. {
  37. public string[] ChannelsToJoinOnConnect; // set in inspector. Demo channels to join automatically.
  38. public string[] FriendsList;
  39. public int HistoryLengthToFetch; // set in inspector. Up to a certain degree, previously sent messages can be fetched for context
  40. public string UserName { get; set; }
  41. private string selectedChannelName; // mainly used for GUI/input
  42. public ChatClient chatClient;
  43. #if !PHOTON_UNITY_NETWORKING
  44. public ChatAppSettings ChatAppSettings
  45. {
  46. get { return this.chatAppSettings; }
  47. }
  48. [SerializeField]
  49. #endif
  50. protected internal ChatAppSettings chatAppSettings;
  51. public GameObject missingAppIdErrorPanel;
  52. public GameObject ConnectingLabel;
  53. public RectTransform ChatPanel; // set in inspector (to enable/disable panel)
  54. public GameObject UserIdFormPanel;
  55. public InputField InputFieldChat; // set in inspector
  56. public Text CurrentChannelText; // set in inspector
  57. public Toggle ChannelToggleToInstantiate; // set in inspector
  58. public GameObject FriendListUiItemtoInstantiate;
  59. private readonly Dictionary<string, Toggle> channelToggles = new Dictionary<string, Toggle>();
  60. private readonly Dictionary<string,FriendItem> friendListItemLUT = new Dictionary<string, FriendItem>();
  61. public bool ShowState = true;
  62. public GameObject Title;
  63. public Text StateText; // set in inspector
  64. public Text UserIdText; // set in inspector
  65. // private static string WelcomeText = "Welcome to chat. Type \\help to list commands.";
  66. private static string HelpText = "\n -- HELP --\n" +
  67. "To subscribe to channel(s) (channelnames are case sensitive) : \n" +
  68. "\t<color=#E07B00>\\subscribe</color> <color=green><list of channelnames></color>\n" +
  69. "\tor\n" +
  70. "\t<color=#E07B00>\\s</color> <color=green><list of channelnames></color>\n" +
  71. "\n" +
  72. "To leave channel(s):\n" +
  73. "\t<color=#E07B00>\\unsubscribe</color> <color=green><list of channelnames></color>\n" +
  74. "\tor\n" +
  75. "\t<color=#E07B00>\\u</color> <color=green><list of channelnames></color>\n" +
  76. "\n" +
  77. "To switch the active channel\n" +
  78. "\t<color=#E07B00>\\join</color> <color=green><channelname></color>\n" +
  79. "\tor\n" +
  80. "\t<color=#E07B00>\\j</color> <color=green><channelname></color>\n" +
  81. "\n" +
  82. "To send a private message: (username are case sensitive)\n" +
  83. "\t\\<color=#E07B00>msg</color> <color=green><username></color> <color=green><message></color>\n" +
  84. "\n" +
  85. "To change status:\n" +
  86. "\t\\<color=#E07B00>state</color> <color=green><stateIndex></color> <color=green><message></color>\n" +
  87. "<color=green>0</color> = Offline " +
  88. "<color=green>1</color> = Invisible " +
  89. "<color=green>2</color> = Online " +
  90. "<color=green>3</color> = Away \n" +
  91. "<color=green>4</color> = Do not disturb " +
  92. "<color=green>5</color> = Looking For Group " +
  93. "<color=green>6</color> = Playing" +
  94. "\n\n" +
  95. "To clear the current chat tab (private chats get closed):\n" +
  96. "\t<color=#E07B00>\\clear</color>";
  97. public void Start()
  98. {
  99. DontDestroyOnLoad(this.gameObject);
  100. this.UserIdText.text = "";
  101. this.StateText.text = "";
  102. this.StateText.gameObject.SetActive(true);
  103. this.UserIdText.gameObject.SetActive(true);
  104. this.Title.SetActive(true);
  105. this.ChatPanel.gameObject.SetActive(false);
  106. this.ConnectingLabel.SetActive(false);
  107. if (string.IsNullOrEmpty(this.UserName))
  108. {
  109. this.UserName = "user" + Environment.TickCount%99; //made-up username
  110. }
  111. #if PHOTON_UNITY_NETWORKING
  112. this.chatAppSettings = PhotonNetwork.PhotonServerSettings.AppSettings.GetChatSettings();
  113. #endif
  114. bool appIdPresent = !string.IsNullOrEmpty(this.chatAppSettings.AppIdChat);
  115. this.missingAppIdErrorPanel.SetActive(!appIdPresent);
  116. this.UserIdFormPanel.gameObject.SetActive(appIdPresent);
  117. if (!appIdPresent)
  118. {
  119. Debug.LogError("You need to set the chat app ID in the PhotonServerSettings file in order to continue.");
  120. }
  121. }
  122. public void Connect()
  123. {
  124. this.UserIdFormPanel.gameObject.SetActive(false);
  125. this.chatClient = new ChatClient(this);
  126. #if !UNITY_WEBGL
  127. this.chatClient.UseBackgroundWorkerForSending = true;
  128. #endif
  129. this.chatClient.AuthValues = new AuthenticationValues(this.UserName);
  130. this.chatClient.ConnectUsingSettings(this.chatAppSettings);
  131. this.ChannelToggleToInstantiate.gameObject.SetActive(false);
  132. Debug.Log("Connecting as: " + this.UserName);
  133. this.ConnectingLabel.SetActive(true);
  134. }
  135. /// <summary>To avoid that the Editor becomes unresponsive, disconnect all Photon connections in OnDestroy.</summary>
  136. public void OnDestroy()
  137. {
  138. if (this.chatClient != null)
  139. {
  140. this.chatClient.Disconnect();
  141. }
  142. }
  143. /// <summary>To avoid that the Editor becomes unresponsive, disconnect all Photon connections in OnApplicationQuit.</summary>
  144. public void OnApplicationQuit()
  145. {
  146. if (this.chatClient != null)
  147. {
  148. this.chatClient.Disconnect();
  149. }
  150. }
  151. public void Update()
  152. {
  153. if (this.chatClient != null)
  154. {
  155. this.chatClient.Service(); // make sure to call this regularly! it limits effort internally, so calling often is ok!
  156. }
  157. // check if we are missing context, which means we got kicked out to get back to the Photon Demo hub.
  158. if ( this.StateText == null)
  159. {
  160. Destroy(this.gameObject);
  161. return;
  162. }
  163. this.StateText.gameObject.SetActive(this.ShowState); // this could be handled more elegantly, but for the demo it's ok.
  164. }
  165. public void OnEnterSend()
  166. {
  167. if (Input.GetKey(KeyCode.Return) || Input.GetKey(KeyCode.KeypadEnter))
  168. {
  169. this.SendChatMessage(this.InputFieldChat.text);
  170. this.InputFieldChat.text = "";
  171. }
  172. }
  173. public void OnClickSend()
  174. {
  175. if (this.InputFieldChat != null)
  176. {
  177. this.SendChatMessage(this.InputFieldChat.text);
  178. this.InputFieldChat.text = "";
  179. }
  180. }
  181. public int TestLength = 2048;
  182. private byte[] testBytes = new byte[2048];
  183. private void SendChatMessage(string inputLine)
  184. {
  185. if (string.IsNullOrEmpty(inputLine))
  186. {
  187. return;
  188. }
  189. if ("test".Equals(inputLine))
  190. {
  191. if (this.TestLength != this.testBytes.Length)
  192. {
  193. this.testBytes = new byte[this.TestLength];
  194. }
  195. this.chatClient.SendPrivateMessage(this.chatClient.AuthValues.UserId, this.testBytes, true);
  196. }
  197. bool doingPrivateChat = this.chatClient.PrivateChannels.ContainsKey(this.selectedChannelName);
  198. string privateChatTarget = string.Empty;
  199. if (doingPrivateChat)
  200. {
  201. // the channel name for a private conversation is (on the client!!) always composed of both user's IDs: "this:remote"
  202. // so the remote ID is simple to figure out
  203. string[] splitNames = this.selectedChannelName.Split(new char[] { ':' });
  204. privateChatTarget = splitNames[1];
  205. }
  206. //UnityEngine.Debug.Log("selectedChannelName: " + selectedChannelName + " doingPrivateChat: " + doingPrivateChat + " privateChatTarget: " + privateChatTarget);
  207. if (inputLine[0].Equals('\\'))
  208. {
  209. string[] tokens = inputLine.Split(new char[] {' '}, 2);
  210. if (tokens[0].Equals("\\help"))
  211. {
  212. this.PostHelpToCurrentChannel();
  213. }
  214. if (tokens[0].Equals("\\state"))
  215. {
  216. int newState = 0;
  217. List<string> messages = new List<string>();
  218. messages.Add ("i am state " + newState);
  219. string[] subtokens = tokens[1].Split(new char[] {' ', ','});
  220. if (subtokens.Length > 0)
  221. {
  222. newState = int.Parse(subtokens[0]);
  223. }
  224. if (subtokens.Length > 1)
  225. {
  226. messages.Add(subtokens[1]);
  227. }
  228. this.chatClient.SetOnlineStatus(newState,messages.ToArray()); // this is how you set your own state and (any) message
  229. }
  230. else if ((tokens[0].Equals("\\subscribe") || tokens[0].Equals("\\s")) && !string.IsNullOrEmpty(tokens[1]))
  231. {
  232. this.chatClient.Subscribe(tokens[1].Split(new char[] {' ', ','}));
  233. }
  234. else if ((tokens[0].Equals("\\unsubscribe") || tokens[0].Equals("\\u")) && !string.IsNullOrEmpty(tokens[1]))
  235. {
  236. this.chatClient.Unsubscribe(tokens[1].Split(new char[] {' ', ','}));
  237. }
  238. else if (tokens[0].Equals("\\clear"))
  239. {
  240. if (doingPrivateChat)
  241. {
  242. this.chatClient.PrivateChannels.Remove(this.selectedChannelName);
  243. }
  244. else
  245. {
  246. ChatChannel channel;
  247. if (this.chatClient.TryGetChannel(this.selectedChannelName, doingPrivateChat, out channel))
  248. {
  249. channel.ClearMessages();
  250. }
  251. }
  252. }
  253. else if (tokens[0].Equals("\\msg") && !string.IsNullOrEmpty(tokens[1]))
  254. {
  255. string[] subtokens = tokens[1].Split(new char[] {' ', ','}, 2);
  256. if (subtokens.Length < 2) return;
  257. string targetUser = subtokens[0];
  258. string message = subtokens[1];
  259. this.chatClient.SendPrivateMessage(targetUser, message);
  260. }
  261. else if ((tokens[0].Equals("\\join") || tokens[0].Equals("\\j")) && !string.IsNullOrEmpty(tokens[1]))
  262. {
  263. string[] subtokens = tokens[1].Split(new char[] { ' ', ',' }, 2);
  264. // If we are already subscribed to the channel we directly switch to it, otherwise we subscribe to it first and then switch to it implicitly
  265. if (this.channelToggles.ContainsKey(subtokens[0]))
  266. {
  267. this.ShowChannel(subtokens[0]);
  268. }
  269. else
  270. {
  271. this.chatClient.Subscribe(new string[] { subtokens[0] });
  272. }
  273. }
  274. #if CHAT_EXTENDED
  275. else if ((tokens[0].Equals("\\nickname") || tokens[0].Equals("\\nick") ||tokens[0].Equals("\\n")) && !string.IsNullOrEmpty(tokens[1]))
  276. {
  277. if (!doingPrivateChat)
  278. {
  279. this.chatClient.SetCustomUserProperties(this.selectedChannelName, this.chatClient.UserId, new Dictionary<string, object> {{"Nickname", tokens[1]}});
  280. }
  281. }
  282. #endif
  283. else
  284. {
  285. Debug.Log("The command '" + tokens[0] + "' is invalid.");
  286. }
  287. }
  288. else
  289. {
  290. if (doingPrivateChat)
  291. {
  292. this.chatClient.SendPrivateMessage(privateChatTarget, inputLine);
  293. }
  294. else
  295. {
  296. this.chatClient.PublishMessage(this.selectedChannelName, inputLine);
  297. }
  298. }
  299. }
  300. public void PostHelpToCurrentChannel()
  301. {
  302. this.CurrentChannelText.text += HelpText;
  303. }
  304. public void DebugReturn(ExitGames.Client.Photon.DebugLevel level, string message)
  305. {
  306. if (level == ExitGames.Client.Photon.DebugLevel.ERROR)
  307. {
  308. Debug.LogError(message);
  309. }
  310. else if (level == ExitGames.Client.Photon.DebugLevel.WARNING)
  311. {
  312. Debug.LogWarning(message);
  313. }
  314. else
  315. {
  316. Debug.Log(message);
  317. }
  318. }
  319. public void OnConnected()
  320. {
  321. if (this.ChannelsToJoinOnConnect != null && this.ChannelsToJoinOnConnect.Length > 0)
  322. {
  323. this.chatClient.Subscribe(this.ChannelsToJoinOnConnect, this.HistoryLengthToFetch);
  324. }
  325. this.ConnectingLabel.SetActive(false);
  326. this.UserIdText.text = "Connected as "+ this.UserName;
  327. this.ChatPanel.gameObject.SetActive(true);
  328. if (this.FriendsList!=null && this.FriendsList.Length>0)
  329. {
  330. this.chatClient.AddFriends(this.FriendsList); // Add some users to the server-list to get their status updates
  331. // add to the UI as well
  332. foreach(string _friend in this.FriendsList)
  333. {
  334. if (this.FriendListUiItemtoInstantiate != null && _friend!= this.UserName)
  335. {
  336. this.InstantiateFriendButton(_friend);
  337. }
  338. }
  339. }
  340. if (this.FriendListUiItemtoInstantiate != null)
  341. {
  342. this.FriendListUiItemtoInstantiate.SetActive(false);
  343. }
  344. this.chatClient.SetOnlineStatus(ChatUserStatus.Online); // You can set your online state (without a mesage).
  345. }
  346. public void OnDisconnected()
  347. {
  348. Debug.Log("OnDisconnected()");
  349. this.ConnectingLabel.SetActive(false);
  350. }
  351. public void OnChatStateChange(ChatState state)
  352. {
  353. // use OnConnected() and OnDisconnected()
  354. // this method might become more useful in the future, when more complex states are being used.
  355. this.StateText.text = state.ToString();
  356. }
  357. public void OnSubscribed(string[] channels, bool[] results)
  358. {
  359. // in this demo, we simply send a message into each channel. This is NOT a must have!
  360. foreach (string channel in channels)
  361. {
  362. this.chatClient.PublishMessage(channel, "says 'hi'."); // you don't HAVE to send a msg on join but you could.
  363. if (this.ChannelToggleToInstantiate != null)
  364. {
  365. this.InstantiateChannelButton(channel);
  366. }
  367. }
  368. Debug.Log("OnSubscribed: " + string.Join(", ", channels));
  369. /*
  370. // select first subscribed channel in alphabetical order
  371. if (this.chatClient.PublicChannels.Count > 0)
  372. {
  373. var l = new List<string>(this.chatClient.PublicChannels.Keys);
  374. l.Sort();
  375. string selected = l[0];
  376. if (this.channelToggles.ContainsKey(selected))
  377. {
  378. ShowChannel(selected);
  379. foreach (var c in this.channelToggles)
  380. {
  381. c.Value.isOn = false;
  382. }
  383. this.channelToggles[selected].isOn = true;
  384. AddMessageToSelectedChannel(WelcomeText);
  385. }
  386. }
  387. */
  388. // Switch to the first newly created channel
  389. this.ShowChannel(channels[0]);
  390. }
  391. /// <inheritdoc />
  392. public void OnSubscribed(string channel, string[] users, Dictionary<object, object> properties)
  393. {
  394. Debug.LogFormat("OnSubscribed: {0}, users.Count: {1} Channel-props: {2}.", channel, users.Length, properties.ToStringFull());
  395. }
  396. private void InstantiateChannelButton(string channelName)
  397. {
  398. if (this.channelToggles.ContainsKey(channelName))
  399. {
  400. Debug.Log("Skipping creation for an existing channel toggle.");
  401. return;
  402. }
  403. Toggle cbtn = (Toggle)Instantiate(this.ChannelToggleToInstantiate);
  404. cbtn.gameObject.SetActive(true);
  405. cbtn.GetComponentInChildren<ChannelSelector>().SetChannel(channelName);
  406. cbtn.transform.SetParent(this.ChannelToggleToInstantiate.transform.parent, false);
  407. this.channelToggles.Add(channelName, cbtn);
  408. }
  409. private void InstantiateFriendButton(string friendId)
  410. {
  411. GameObject fbtn = (GameObject)Instantiate(this.FriendListUiItemtoInstantiate);
  412. fbtn.gameObject.SetActive(true);
  413. FriendItem _friendItem = fbtn.GetComponent<FriendItem>();
  414. _friendItem.FriendId = friendId;
  415. fbtn.transform.SetParent(this.FriendListUiItemtoInstantiate.transform.parent, false);
  416. this.friendListItemLUT[friendId] = _friendItem;
  417. }
  418. public void OnUnsubscribed(string[] channels)
  419. {
  420. foreach (string channelName in channels)
  421. {
  422. if (this.channelToggles.ContainsKey(channelName))
  423. {
  424. Toggle t = this.channelToggles[channelName];
  425. Destroy(t.gameObject);
  426. this.channelToggles.Remove(channelName);
  427. Debug.Log("Unsubscribed from channel '" + channelName + "'.");
  428. // Showing another channel if the active channel is the one we unsubscribed from before
  429. if (channelName == this.selectedChannelName && this.channelToggles.Count > 0)
  430. {
  431. IEnumerator<KeyValuePair<string, Toggle>> firstEntry = this.channelToggles.GetEnumerator();
  432. firstEntry.MoveNext();
  433. this.ShowChannel(firstEntry.Current.Key);
  434. firstEntry.Current.Value.isOn = true;
  435. }
  436. }
  437. else
  438. {
  439. Debug.Log("Can't unsubscribe from channel '" + channelName + "' because you are currently not subscribed to it.");
  440. }
  441. }
  442. }
  443. public void OnGetMessages(string channelName, string[] senders, object[] messages)
  444. {
  445. if (channelName.Equals(this.selectedChannelName))
  446. {
  447. // update text
  448. this.ShowChannel(this.selectedChannelName);
  449. }
  450. }
  451. public void OnPrivateMessage(string sender, object message, string channelName)
  452. {
  453. // as the ChatClient is buffering the messages for you, this GUI doesn't need to do anything here
  454. // you also get messages that you sent yourself. in that case, the channelName is determinded by the target of your msg
  455. this.InstantiateChannelButton(channelName);
  456. byte[] msgBytes = message as byte[];
  457. if (msgBytes != null)
  458. {
  459. Debug.Log("Message with byte[].Length: "+ msgBytes.Length);
  460. }
  461. if (this.selectedChannelName.Equals(channelName))
  462. {
  463. this.ShowChannel(channelName);
  464. }
  465. }
  466. /// <summary>
  467. /// New status of another user (you get updates for users set in your friends list).
  468. /// </summary>
  469. /// <param name="user">Name of the user.</param>
  470. /// <param name="status">New status of that user.</param>
  471. /// <param name="gotMessage">True if the status contains a message you should cache locally. False: This status update does not include a
  472. /// message (keep any you have).</param>
  473. /// <param name="message">Message that user set.</param>
  474. public void OnStatusUpdate(string user, int status, bool gotMessage, object message)
  475. {
  476. Debug.LogWarning("status: " + string.Format("{0} is {1}. Msg:{2}", user, status, message));
  477. if (this.friendListItemLUT.ContainsKey(user))
  478. {
  479. FriendItem _friendItem = this.friendListItemLUT[user];
  480. if ( _friendItem!=null) _friendItem.OnFriendStatusUpdate(status,gotMessage,message);
  481. }
  482. }
  483. public void OnUserSubscribed(string channel, string user)
  484. {
  485. Debug.LogFormat("OnUserSubscribed: channel=\"{0}\" userId=\"{1}\"", channel, user);
  486. }
  487. public void OnUserUnsubscribed(string channel, string user)
  488. {
  489. Debug.LogFormat("OnUserUnsubscribed: channel=\"{0}\" userId=\"{1}\"", channel, user);
  490. }
  491. /// <inheritdoc />
  492. public void OnChannelPropertiesChanged(string channel, string userId, Dictionary<object, object> properties)
  493. {
  494. Debug.LogFormat("OnChannelPropertiesChanged: {0} by {1}. Props: {2}.", channel, userId, Extensions.ToStringFull(properties));
  495. }
  496. public void OnUserPropertiesChanged(string channel, string targetUserId, string senderUserId, Dictionary<object, object> properties)
  497. {
  498. Debug.LogFormat("OnUserPropertiesChanged: (channel:{0} user:{1}) by {2}. Props: {3}.", channel, targetUserId, senderUserId, Extensions.ToStringFull(properties));
  499. }
  500. /// <inheritdoc />
  501. public void OnErrorInfo(string channel, string error, object data)
  502. {
  503. Debug.LogFormat("OnErrorInfo for channel {0}. Error: {1} Data: {2}", channel, error, data);
  504. }
  505. public void AddMessageToSelectedChannel(string msg)
  506. {
  507. ChatChannel channel = null;
  508. bool found = this.chatClient.TryGetChannel(this.selectedChannelName, out channel);
  509. if (!found)
  510. {
  511. Debug.Log("AddMessageToSelectedChannel failed to find channel: " + this.selectedChannelName);
  512. return;
  513. }
  514. if (channel != null)
  515. {
  516. channel.Add("Bot", msg,0); //TODO: how to use msgID?
  517. }
  518. }
  519. public void ShowChannel(string channelName)
  520. {
  521. if (string.IsNullOrEmpty(channelName))
  522. {
  523. return;
  524. }
  525. ChatChannel channel = null;
  526. bool found = this.chatClient.TryGetChannel(channelName, out channel);
  527. if (!found)
  528. {
  529. Debug.Log("ShowChannel failed to find channel: " + channelName);
  530. return;
  531. }
  532. this.selectedChannelName = channelName;
  533. this.CurrentChannelText.text = channel.ToStringMessages();
  534. Debug.Log("ShowChannel: " + this.selectedChannelName);
  535. foreach (KeyValuePair<string, Toggle> pair in this.channelToggles)
  536. {
  537. pair.Value.isOn = pair.Key == channelName ? true : false;
  538. }
  539. }
  540. public void OpenDashboard()
  541. {
  542. Application.OpenURL("https://dashboard.photonengine.com");
  543. }
  544. }
  545. }