Ejemplo n.º 1
0
        async Task <bool> SetupAsync()
        {
            var task  = new TaskCompletionSource <bool>();
            var token = await TwilioHelper.GetTokenAsync();

            var accessManager = TwilioAccessManagerFactory.CreateAccessManager(token, this);

            Client = TwilioIPMessagingSDK.CreateIPMessagingClientWithAccessManager(accessManager, this);

            Client.Channels.LoadChannelsWithListener(new StatusListener
            {
                SuccessHandler = () =>
                {
                    GeneralChannel = Client.Channels.GetChannelByUniqueName("general");

                    if (GeneralChannel != null)
                    {
                        GeneralChannel.Listener = this;
                        JoinGeneralChannel();
                    }
                    else
                    {
                        CreateAndJoinGeneralChannel();
                    }

                    task.SetResult(true);
                }
            });

            return(await task.Task.ConfigureAwait(false));
        }
        async Task Setup()
        {
            var token = await GetIdentity();

            var accessManager = TwilioAccessManagerFactory.CreateAccessManager(token, this);

            client = TwilioIPMessagingSDK.CreateIPMessagingClientWithAccessManager(accessManager, this);

            client.Channels.LoadChannelsWithListener(new StatusListener
            {
                SuccessHandler = () =>
                {
                    generalChannel = client.Channels.GetChannelByUniqueName("general");

                    if (generalChannel != null)
                    {
                        generalChannel.Listener = this;
                        JoinGeneralChannel();
                    }
                    else
                    {
                        CreateAndJoinGeneralChannel();
                    }
                }
            });
        }
Ejemplo n.º 3
0
        async Task <bool> Conectar()
        {
            var task  = new TaskCompletionSource <bool>();
            var token = await TokenControll.RecuperarToken();

            var accessManager = TwilioAccessManagerFactory.CreateAccessManager(token, this);

            Client = TwilioIPMessagingSDK.CreateIPMessagingClientWithAccessManager(accessManager, this);

            return(await task.Task.ConfigureAwait(false));
        }