Which session triggered the event?

I’m trying to use 2 sessions.

If I understood the FAQ correctly, I should do it like this.

    static async Task Main(string[] _)
        Helpers.Log = (l, s) => Debug.WriteLine(s);
        Clients.Add(new Client(what => Config(what, "session1")));
        Clients.Add(new Client(what => Config(what, "session2")));

        for (int i = 0; i < Clients.Count; i++)
            Clients[i].OnUpdate += Client_OnUpdate;
            MyUsers.Add(new User());
            MyUsers[i] = await Clients[i].LoginUserIfNeeded();
            var dialogs = await Clients[i].Messages_GetAllDialogs();
            dialogs.CollectUsersChats(Users, Chats);


But I can’t figure out which session I’m getting the message from. How can I understand this ?

In IObject arg I could not find this information, because I do not have enough knowledge(

Client_OnUpdate(IObject arg)

>Solution :

modify your Client_OnUpdate to take an extra i argument, and register it like that:

Clients[i].OnUpdate += updates => Client_OnUpdate(updates, i)

You might want to learn more about lambda expressions…

Leave a Reply