Exemplo n.º 1
0
        private void SubscribeToEvents()
        {
            _subscriptions.Apply(x => x.Dispose());
            _subscriptions.Clear();

            #region Channel

            _subscriptions.Add(_connection.On <ChannelSummaryResponse>(ClientEvents.ChannelUpdated,
                                                                       channel =>
            {
                ChannelUpdated?.Invoke(channel);
            }));

            _subscriptions.Add(_connection.On <Guid>(ClientEvents.ChannelClosed,
                                                     channelId =>
            {
                ChannelClosed?.Invoke(channelId);
            }));

            #endregion

            #region Message

            _subscriptions.Add(_connection.On <MessageResponse>(ClientEvents.MessageAdded,
                                                                message =>
            {
                MessageAdded?.Invoke(message);
            }));

            _subscriptions.Add(_connection.On <MessageResponse>(ClientEvents.MessageUpdated,
                                                                message =>
            {
                MessageUpdated?.Invoke(message);
            }));

            _subscriptions.Add(_connection.On <Guid, Guid>(ClientEvents.MessageDeleted,
                                                           (deletedMessageId, channelId) =>
            {
                MessageDeleted?.Invoke(deletedMessageId, channelId);
            }));

            _subscriptions.Add(_connection.On <Guid>(ClientEvents.LastReadMessageChanged,
                                                     channelId =>
            {
                LastReadMessageUpdated?.Invoke(channelId);
            }));

            #endregion

            #region Member

            _subscriptions.Add(_connection.On <ChannelSummaryResponse>(ClientEvents.MemberJoined,
                                                                       (channel) =>
            {
                MemberJoined?.Invoke(channel);
            }));

            _subscriptions.Add(_connection.On <Guid>(ClientEvents.MemberLeft,
                                                     (channelId) =>
            {
                MemberLeft?.Invoke(channelId);
            }));

            _subscriptions.Add(_connection.On <MemberSummaryResponse, Guid>(ClientEvents.MemberDeleted,
                                                                            (member, channelId) =>
            {
                MemberDeleted?.Invoke(member, channelId);
            }));

            #endregion
        }
Exemplo n.º 2
0
 protected virtual void OnMemberLeft(LobbyMember member)
 {
     MemberLeft?.Invoke(this, new MemberEventArgs(member));
 }