Beispiel #1
0
    public override async void Show()
    {
        base.Show();

        LCIMClient client = LCManager.Instance.IMClient;

        client.OnMessage += OnMessage;
        LCIMChatRoom chatRoom = await client.GetConversation(WordConversationId) as LCIMChatRoom;

        await chatRoom.Join();
    }
Beispiel #2
0
        public async Task CreateChatRoom()
        {
            string     clientId = Guid.NewGuid().ToString();
            LCIMClient client   = new LCIMClient(clientId);

            await client.Open();

            client.OnInvited = (conv, initBy) => {
                WriteLine($"on invited: {initBy}");
            };

            string           name         = Guid.NewGuid().ToString();
            LCIMConversation conversation = await client.CreateChatRoom(name);

            string     visitorId = Guid.NewGuid().ToString();
            LCIMClient visitor   = new LCIMClient(visitorId);

            await visitor.Open();

            LCIMChatRoom chatRoom = await visitor.GetConversation(conversation.Id) as LCIMChatRoom;

            await chatRoom.Join();

            LCIMTextMessage textMessage = new LCIMTextMessage("hello, world");
            await conversation.Send(textMessage);

            int count = await chatRoom.GetMembersCount();

            ReadOnlyCollection <string> onlineMembers = await chatRoom.GetOnlineMembers();

            Assert.GreaterOrEqual(onlineMembers.Count, 1);
            foreach (string memberId in onlineMembers)
            {
                WriteLine($"{memberId} online");
            }

            await client.Close();

            await visitor.Close();
        }