// GET: SendBird public ActionResult Index() { string APP_ID = "75DC34C9-03AE-4573-A69A-63FD75B7300E"; //SendBirdClient.Init(APP_ID); //var result = ""; string USE_ID = "T_tin2"; //string ACCESS_TOKEN = "c4a2132e3b709eb947cb00b7a1c4c3326d66853c"; SendBirdClient.Init(APP_ID); SendBirdClient.ChannelHandler channelHandler = new SendBirdClient.ChannelHandler(); channelHandler.OnMessageReceived = (BaseChannel baseChannel, BaseMessage baseMessage) => { //baseMessage.MessageId.ToString(); // message received }; SendBirdClient.AddChannelHandler("testchannel1", channelHandler); SendBirdClient.Connect(USE_ID, (User user, SendBirdException connectException) => { // get channel GroupChannel.GetChannel("sendbird_group_channel_137287723_07e33e8b58e8f3d71f7a7cccb829ccc3ffbfa96c", (GroupChannel groupChannel, SendBirdException getChannelException) => { // send message //groupChannel.SendUserMessage("you welcome.", // (UserMessage userMessage, SendBirdException sendMessageException) => { // // message sent // }); }); }); return(View()); }
public Task <GroupChannel> GetUsersInChannel(string channelUrl) { var tcs = new TaskCompletionSource <GroupChannel>(); GroupChannel.GetChannel(channelUrl, (channel, e) => { if (e != null) { tcs.TrySetCanceled(); } else { tcs.TrySetResult(channel); } }); Debug.WriteLine("Getting users in Channels"); return(tcs.Task); }
void InitComponents() { uiPanel = GameObject.Find("SendBirdUnity/UIPanel"); (Instantiate(uiThemePrefab) as GameObject).transform.parent = uiPanel.transform; editPopup = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/EditPopup"); editPopup.gameObject.SetActive(false); uiTheme = GameObject.FindObjectOfType(typeof(SendBirdTheme)) as SendBirdTheme; #region MenuPanel menuPanel = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel"); menuPanel.GetComponent <Image>().sprite = uiTheme.channelListFrameBG; var txtMenuTitle = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/TxtTitle").GetComponent <Text>(); txtMenuTitle.color = uiTheme.titleColor; btnConnect = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/BtnConnect").GetComponent <Button>(); btnConnect.GetComponent <Image>().sprite = uiTheme.sendButton; btnConnect.GetComponent <Image>().type = Image.Type.Sliced; btnConnect.onClick.AddListener(() => { nickname = inputUserName.text; userId = nickname; // Please assign user's unique id. if (nickname == null || nickname.Length <= 0) { return; } btnConnect.gameObject.SetActive(false); btnOpenChannelList.gameObject.SetActive(true); btnStartGroupChannel.gameObject.SetActive(true); btnGroupChannelList.gameObject.SetActive(true); SendBirdClient.Connect(userId, (user, e) => { // if (e != null) { Debug.Log(e.Code + ": " + e.Message); return; } SendBirdClient.UpdateCurrentUserInfo(nickname, null, (e1) => { if (e1 != null) { Debug.Log(e.Code + ": " + e.Message); return; } }); }); }); btnOpenChannelList = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/BtnOpenChannel").GetComponent <Button>(); btnOpenChannelList.GetComponent <Image>().sprite = uiTheme.sendButton; btnOpenChannelList.GetComponent <Image>().type = Image.Type.Sliced; btnOpenChannelList.onClick.AddListener(() => { menuPanel.SetActive(false); OpenOpenChannelList(); }); btnStartGroupChannel = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/BtnStartGroupChannel").GetComponent <Button>(); btnStartGroupChannel.GetComponent <Image>().sprite = uiTheme.sendButton; btnStartGroupChannel.GetComponent <Image>().type = Image.Type.Sliced; btnStartGroupChannel.onClick.AddListener(() => { menuPanel.SetActive(false); OpenUserList(); }); btnGroupChannelList = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/BtnGroupChannel").GetComponent <Button>(); btnGroupChannelList.GetComponent <Image>().sprite = uiTheme.sendButton; btnGroupChannelList.GetComponent <Image>().type = Image.Type.Sliced; btnGroupChannelList.onClick.AddListener(() => { menuPanel.SetActive(false); OpenGroupChannelList(); }); inputUserName = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/InputUserName").GetComponent <InputField>(); inputUserName.GetComponent <Image>().sprite = uiTheme.inputTextBG; #endregion #region OpenChannel openChannelPanel = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel"); openChannelPanel.GetComponent <Image>().sprite = uiTheme.chatFrameBG; txtOpenChannelContent = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/ScrollArea/TxtContent").GetComponent <Text>(); // (Text); txtOpenChannelContent.color = uiTheme.messageColor; txtOpenChannelTitle = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/TxtTitle").GetComponent <Text>(); txtOpenChannelTitle.color = uiTheme.titleColor; openChannelScrollbar = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/Scrollbar").GetComponent <Scrollbar>(); ColorBlock cb = openChannelScrollbar.colors; cb.normalColor = uiTheme.scrollBarColor; cb.pressedColor = uiTheme.scrollBarColor; cb.highlightedColor = uiTheme.scrollBarColor; openChannelScrollbar.colors = cb; openChannelScrollbar.onValueChanged.AddListener((float value) => { if (value <= 0) { autoScroll = true; lastTextPositionY = txtOpenChannelContent.transform.position.y; return; } if (lastTextPositionY - txtOpenChannelContent.transform.position.y >= 100) { autoScroll = false; } lastTextPositionY = txtOpenChannelContent.transform.position.y; }); inputOpenChannel = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/InputOpenChannel").GetComponent <InputField>(); inputOpenChannel.GetComponent <Image>().sprite = uiTheme.inputTextBG; inputOpenChannel.onEndEdit.AddListener((string msg) => { SubmitOpenChannel(); }); GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/InputOpenChannel/Placeholder").GetComponent <Text>().color = uiTheme.inputTextPlaceholderColor; GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/InputOpenChannel/Text").GetComponent <Text>().color = uiTheme.inputTextColor; btnOpenChannelSend = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/BtnOpenChannelSend").GetComponent <Button>(); btnOpenChannelSend.GetComponent <Image>().sprite = uiTheme.sendButton; btnOpenChannelSend.GetComponentInChildren <Text>().color = uiTheme.sendButtonColor; btnOpenChannelSend.onClick.AddListener(() => { SubmitOpenChannel(); }); btnOpenChannelClose = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/BtnOpenChannelClose").GetComponent <Button>(); btnOpenChannelClose.GetComponent <Image>().sprite = uiTheme.closeButton; btnOpenChannelClose.onClick.AddListener(() => { openChannelPanel.SetActive(false); menuPanel.SetActive(true); }); #endregion #region ChannelList openChannelListPanel = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel"); openChannelListPanel.GetComponent <Image>().sprite = uiTheme.channelListFrameBG; channelGridPannel = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel/ScrollArea/GridPanel"); GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel/TxtTitle").GetComponent <Text>().color = uiTheme.titleColor; var channelScrollbar = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel/Scrollbar").GetComponent <Scrollbar>(); cb = channelScrollbar.colors; cb.normalColor = uiTheme.scrollBarColor; cb.pressedColor = uiTheme.scrollBarColor; cb.highlightedColor = uiTheme.scrollBarColor; channelScrollbar.colors = cb; channelScrollbar.onValueChanged.AddListener((float value) => { if (value <= 0) { LoadOpenChannels(); } }); btnOpenChannelListClose = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel/BtnOpenChannelListClose").GetComponent <Button>(); btnOpenChannelListClose.GetComponent <Image>().sprite = uiTheme.closeButton; btnOpenChannelListClose.onClick.AddListener(() => { openChannelListPanel.SetActive(false); menuPanel.SetActive(true); }); #endregion #region GroupChannel groupChannelPanel = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel"); groupChannelPanel.GetComponent <Image>().sprite = uiTheme.chatFrameBG; txtGroupChannelTitle = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/TxtTitle").GetComponent <Text>(); txtGroupChannelTitle.color = uiTheme.titleColor; groupScrollArea = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/ScrollArea"); editableScrollArea = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/EditableScrollArea"); editableGridPannel = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/EditableScrollArea/GridPanel"); btnGroupChannelLeave = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/BtnGroupChannelLeave").GetComponent <Button>(); btnGroupChannelLeave.GetComponent <Image>().sprite = uiTheme.channelButtonOff; btnGroupChannelLeave.onClick.AddListener(() => { groupChannelPanel.SetActive(false); menuPanel.SetActive(true); foreach (UnityEngine.Object obj in btnMessage) { GameObject.Destroy(obj); } btnMessage.Clear(); string channelUrl = currentChannel.Url; GroupChannel.GetChannel(channelUrl, new GroupChannel.GroupChannelGetHandler((GroupChannel groupChannel1, SendBirdException e1) => { try { if (e1 != null) { } groupChannel1.Leave(new GroupChannel.GroupChannelLeaveHandler((SendBirdException e2) => { })); // When you delete a Group Channel you no longer use if (groupChannel1.Members.Count == 0) { groupChannel1.DeleteChannel(channelUrl, new GroupChannel.GroupChannelLeaveHandler((SendBirdException e3) => { })); } } catch (Exception z) { Debug.Log(z); } })); }); btnGroupChannelClose = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/BtnGroupChannelClose").GetComponent <Button>(); btnGroupChannelClose.GetComponent <Image>().sprite = uiTheme.closeButton; btnGroupChannelClose.onClick.AddListener(() => { groupChannelPanel.SetActive(false); menuPanel.SetActive(true); // sskim add string channelUrl = currentChannel.Url; GroupChannel.GetChannel(channelUrl, new GroupChannel.GroupChannelGetHandler((GroupChannel groupChannel1, SendBirdException e1) => { try { if (e1 != null) { } groupChannelListPanel.SetActive(false); } catch (Exception z) { Debug.Log(z); } })); }); txtGroupChannelContent = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/ScrollArea/TxtContent").GetComponent <Text>(); // (Text); txtGroupChannelContent.color = uiTheme.messageColor; //txtGroupChannelContent2 = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/EditableScrollArea/GridPanel/PrevChatListItem/TxtContent").GetComponent<Text>(); // (Text); //txtGroupChannelContent2.color = uiTheme.messageColor; txtGroupChannelTitle = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/TxtTitle").GetComponent <Text>(); txtGroupChannelTitle.color = uiTheme.titleColor; groupChannelScrollbar = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/ScrollArea/Scrollbar").GetComponent <Scrollbar>(); ColorBlock cb_groupChannel = groupChannelScrollbar.colors; cb_groupChannel.normalColor = uiTheme.scrollBarColor; cb_groupChannel.pressedColor = uiTheme.scrollBarColor; cb_groupChannel.highlightedColor = uiTheme.scrollBarColor; groupChannelScrollbar.colors = cb_groupChannel; groupChannelScrollbar.onValueChanged.AddListener((float value) => { if (value <= 0) { autoScroll = true; lastTextPositionY = txtGroupChannelContent.transform.position.y; return; } if (lastTextPositionY - txtGroupChannelContent.transform.position.y >= 30) { autoScroll = false; } lastTextPositionY = txtGroupChannelContent.transform.position.y; }); inputGroupChannel = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/InputGroupChannel").GetComponent <InputField>(); inputGroupChannel.GetComponent <Image>().sprite = uiTheme.inputTextBG; inputGroupChannel.onEndEdit.AddListener((string msg) => { SubmitGroupChannel(); }); GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/InputGroupChannel/Placeholder").GetComponent <Text>().color = uiTheme.inputTextPlaceholderColor; GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/InputGroupChannel/Text").GetComponent <Text>().color = uiTheme.inputTextColor; btnGroupChannelSend = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/BtnGroupChannelSend").GetComponent <Button>(); btnGroupChannelSend.GetComponent <Image>().sprite = uiTheme.sendButton; btnGroupChannelSend.GetComponentInChildren <Text>().color = uiTheme.sendButtonColor; btnGroupChannelSend.onClick.AddListener(() => { SubmitGroupChannel(); }); groupChannelScrollbar2 = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/EditableScrollArea/Scrollbar2").GetComponent <Scrollbar>(); cb = groupChannelScrollbar2.colors; cb.normalColor = uiTheme.scrollBarColor; cb.pressedColor = uiTheme.scrollBarColor; cb.highlightedColor = uiTheme.scrollBarColor; groupChannelScrollbar2.colors = cb; groupChannelScrollbar2.onValueChanged.AddListener((float value) => { if (btnMessage.Count > 0) { if (value <= 0) { autoScroll = true; lastTextPositionY = ((GameObject)btnMessage[btnMessage.Count - 1]).transform.position.y; return; } if (lastTextPositionY - ((GameObject)btnMessage[btnMessage.Count - 1]).transform.position.y >= 30) { autoScroll = false; } lastTextPositionY = ((GameObject)btnMessage[btnMessage.Count - 1]).transform.position.y; } }); #endregion #region UserList userListPanel = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel"); userListPanel.GetComponent <Image>().sprite = uiTheme.channelListFrameBG; userListGridPanel = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/ScrollArea/GridPanel"); GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/TxtTitle").GetComponent <Text>().color = uiTheme.titleColor; var userListScrollBar = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/Scrollbar").GetComponent <Scrollbar>(); cb = userListScrollBar.colors; cb.normalColor = uiTheme.scrollBarColor; cb.pressedColor = uiTheme.scrollBarColor; cb.highlightedColor = uiTheme.scrollBarColor; userListScrollBar.colors = cb; userListScrollBar.onValueChanged.AddListener((float value) => { if (value <= 0) { LoadUsers(); } }); btnUserListClose = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/BtnUserListClose").GetComponent <Button>(); btnUserListClose.GetComponent <Image>().sprite = uiTheme.closeButton; btnUserListClose.onClick.AddListener(() => { userListPanel.SetActive(false); menuPanel.SetActive(true); }); btnInvite = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/BtnInvite").GetComponent <Button>(); btnInvite.GetComponent <Image>().sprite = uiTheme.sendButton; btnInvite.onClick.AddListener(() => { if (mUserList.Count <= 0) { Debug.Log("Please select one or more."); return; } GroupChannel.CreateChannelWithUserIds(mUserList, false, (channel, e) => { if (e != null) { Debug.Log(e.Code + ": " + e.Message); return; } userListPanel.SetActive(false); editableScrollArea.SetActive(true); groupScrollArea.SetActive(false); groupChannelPanel.SetActive(true); currentChannel = channel; ResetGroupChannelContent(); txtGroupChannelTitle.text = channel.Name + ":" + GetDisplayMemberNames(channel.Members); }); }); #endregion #region GroupChannelList groupChannelListPanel = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel"); groupChannelListPanel.GetComponent <Image>().sprite = uiTheme.channelListFrameBG; groupChannelListGridPanel = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel/ScrollArea/GridPanel"); GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel/TxtTitle").GetComponent <Text>().color = uiTheme.titleColor; var groupChannelListScrollbar = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel/Scrollbar").GetComponent <Scrollbar>(); cb = groupChannelListScrollbar.colors; cb.normalColor = uiTheme.scrollBarColor; cb.pressedColor = uiTheme.scrollBarColor; cb.highlightedColor = uiTheme.scrollBarColor; groupChannelListScrollbar.colors = cb; groupChannelListScrollbar.onValueChanged.AddListener((float value) => { if (value <= 0) { LoadGroupChannels(); } }); btnGroupChannelClose = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel/BtnGroupChannelListClose").GetComponent <Button>(); btnGroupChannelClose.GetComponent <Image>().sprite = uiTheme.closeButton; btnGroupChannelClose.onClick.AddListener(() => { groupChannelListPanel.SetActive(false); if (!groupChannelListPanel.activeSelf) { menuPanel.SetActive(true); } }); #endregion uiPanel.SetActive(true); menuPanel.SetActive(true); openChannelListPanel.SetActive(false); openChannelPanel.SetActive(false); groupChannelPanel.SetActive(false); userListPanel.SetActive(false); groupChannelListPanel.SetActive(false); }