Exemplo n.º 1
0
    public void CreateChannel(string name, Action <OpenChannel, Exception> onChannelCreated)
    {
        var code = Math.Abs(name.GetHashCode()).ToString().Substring(0, 6);

        OpenChannel.CreateChannel(name, null, code.ToString(), (channel, e) =>
        {
            if (e != null)
            {
                Debug.LogError(e);
            }
            onChannelCreated?.Invoke(channel, e);
        });
    }
        private async Task <OpenChannel> CreateChannel(string channelName)
        {
            var         tcs     = new TaskCompletionSource <SendBirdException>();
            OpenChannel channel = null;

            OpenChannel.CreateChannel(channelName, null, null, (openChannel, ex) => {
                Console.WriteLine($"SendBird: Created channel \"{openChannel.Name}\"");
                channel = openChannel;
                tcs.SetResult(ex);
            });

            HandleException(await tcs.Task);
            return(channel);
        }