daemon
(Alex)
9월 21, 2021, 3:19오후
1
안녕하세요!
테마 컴포넌트를 사용하거나 플러그인을 강화하여
온라인인 사용자뿐만 아니라 그들이 지금 무엇을 하고 있는지도 표시할 수 있을까요?
Discourse를 사용하기 전에는 SMF(simplemachines.org )를 많이 사용했는데, 그곳에서는 온라인 상태인 사용자가 현재 무엇을 하고 있는지 볼 수 있었습니다.
이것은 플러그인이나 추가 기능이 아니라 SMF의 기본 내장 기능입니다.
1개의 좋아요
현재 코어에서 이와 유사한 기능을 계획하고 있지는 않습니다(원하는지도 모르겠네요. 우리는 비동기성을 선호하는 편인데, 모든 사용자가 특정 시점에 무엇을 하고 있는지를 아는 것은 그와 정반대이니까요!)
어쨌든 플러그인에서는 가능할 것입니다… 최근 PresenceChannel API를 추가하여 이 유형의 작업을 더 쉽게 만들었습니다:
committed 03:26PM - 27 Aug 21 UTC
PresenceChannel aims to be a generic system for allow the server, and end-users,… to track the number and identity of users performing a specific task on the site. For example, it might be used to track who is currently 'replying' to a specific topic, editing a specific wiki post, etc.
A few key pieces of information about the system:
- PresenceChannels are identified by a name of the format `/prefix/blah`, where `prefix` has been configured by some core/plugin implementation, and `blah` can be any string the implementation wants to use.
- Presence is a boolean thing - each user is either present, or not present. If a user has multiple clients 'present' in a channel, they will be deduplicated so that the user is only counted once
- Developers can configure the existence and configuration of channels 'just in time' using a callback. The result of this is cached for 2 minutes.
- Configuration of a channel can specify permissions in a similar way to MessageBus (public boolean, a list of allowed_user_ids, and a list of allowed_group_ids). A channel can also be placed in 'count_only' mode, where the identity of present users is not revealed to end-users.
- The backend implementation uses redis lua scripts, and is designed to scale well. In the future, hard limits may be introduced on the maximum number of users that can be present in a channel.
- Clients can enter/leave at will. If a client has not marked itself 'present' in the last 60 seconds, they will automatically 'leave' the channel. The JS implementation takes care of this regular check-in.
- On the client-side, PresenceChannel instances can be fetched from the `presence` ember service. Each PresenceChannel can be used entered/left/subscribed/unsubscribed, and the service will automatically deduplicate information before interacting with the server.
- When a client joins a PresenceChannel, the JS implementation will automatically make a GET request for the current channel state. To avoid this, the channel state can be serialized into one of your existing endpoints, and then passed to the `subscribe` method on the channel.
- The PresenceChannel JS object is an ember object. The `users` and `count` property can be used directly in ember templates, and in computed properties.
- It is important to make sure that you `unsubscribe()` and `leave()` any PresenceChannel objects after use
An example implementation may look something like this. On the server:
```ruby
register_presence_channel_prefix("site") do |channel|
next nil unless channel == "/site/online"
PresenceChannel::Config.new(public: true)
end
```
And on the client, a component could be implemented like this:
```javascript
import Component from "@ember/component";
import { inject as service } from "@ember/service";
export default Component.extend({
presence: service(),
init() {
this._super(...arguments);
this.set("presenceChannel", this.presence.getChannel("/site/online"));
},
didInsertElement() {
this.presenceChannel.enter();
this.presenceChannel.subscribe();
},
willDestroyElement() {
this.presenceChannel.leave();
this.presenceChannel.unsubscribe();
},
});
```
With this template:
```handlebars
Online: {{presenceChannel.count}}
<ul>
{{#each presenceChannel.users as |user|}}
<li>{{avatar user imageSize="tiny"}} {{user.username}}</li>
{{/each}}
</ul>
```
8개의 좋아요
daemon
(Alex)
9월 21, 2021, 4:34오후
3
답변해 주셔서 감사합니다!
핵심 기능이 되어야 한다고 말한 것이 아니라, 플러그인이나 테마 컴포넌트로 이 기능이 가능한지 물어본 것입니다.
그리고, 당신의 논리는 다소 이상합니다. 왜냐하면 특정 주제(또는 개인 메시지)에서 누군가가 답변을 작성하고 있을 때, 해당 사용자가 현재 작성 중이라는 것을 확인할 수 있기 때문입니다. 즉, 시스템은 각 사용자가 현재 무엇을 하고 있는지 알고 있는 셈입니다.
저는 Ruby에 익숙하지 않아서 플러그인을 만들 수 없습니다.
2개의 좋아요
맞습니다, 제 실수였어요! SMF의 내장 기능으로 언급된 부분을 지나치게 해석해버렸네요.
그렇긴 하지만, 같은 시간에 같은 장소에 있어야 한다는 제약이 있죠… 거기에는 약간의 장벽이 있습니다. 같은 주제에서 누군가가 입력 중이라는 것을 볼 수 있는 것의 유용성도 제 생각에는 분명해 보입니다… 예를 들어 메타(Meta)에서는 우리 팀의 누군가가 답변을 작성 중이라는 것을 보면, 나는 안심하고 다른 일을 처리할 수 있거든요.
별도의 페이지에 존재감(온라인 상태)을 표시하면 누군가를 몰래 감시하거나 과도하게 관리하기가 훨씬 쉬워지는데, 그런 유형의 행동 외에는 유용성이 제 생각에는 덜 명확해 보입니다. 어떤 사용 사례를 염두에 두고 계신가요? 그걸 알면 도움이 될 수 있을 것 같습니다.
괜찮습니다! 커뮤니티에서 이를 구축하는 데 관심이 있는 다른 사람이 있을 수 있으니, 그것이 기능을 공개적으로 논의하는 것의 장점 중 하나입니다.
7개의 좋아요
daemon
(Alex)
9월 22, 2021, 9:18오후
5
답장 주셔서 감사합니다. 그리고 늦게 답장 드려서 죄송합니다!
필요하지 않습니다. SMF에서 알고 있어서 그렇습니다.
ccstone
(Christopher Stone)
1월 1, 2023, 12:35오전
6
여러분, 안녕하세요.
제가 ‘Who’s Online’ 플러그인의 존재를 최근에야 알게 되었는데요, 이 플러그인은 꽤 마음에 들지만, 옵트아웃을 하려면 사용자의 존재를 완전히 숨기도록(공개 프로필 및 존재 기능 숨기기 ) 요구하는 것은 과도하다고 생각합니다.
제 생각에는 단순히 ‘Who’s Online’ 기능만 옵트아웃할 수 있어야 합니다.
제가 수년간 다른 포럼에서 본 사용자 배려 옵션 중 가장 합리적이고 책임감 있는 방법이라고 생각합니다.
-크리스