insidegui / insidegui/MultipeerKit

additional, custom, local info in Peer

Đang mở
#23 8 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Swift
Star
1.1k
Fork
79
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hi,

although I try to minimize states, in an upcoming project I could use additional, local state information inside a `Peer`, e.g.

- last "heartbeat" timestamp
- a "busy" state
- additional ready/in-sync state on top of `isConnected`

Normally I would subclass `Peer` but MultiPeerKit would not use it obviously. In rare cases I would use objc dynamic runtime and add an "object association" but `Peer` is a struct.

Currently, a "wrapper" would be needed to map an additional local struct to a peer. This creates update problems, keeping the local struct and the peer list in sync - an ugly and weak approach.

I thought about the common `userInfo` dict approach each `Peer` could offer for custom key-values. Sadly this is not very Swift-friendly although a local extension with computed properties could hide the dict.

This `userInfo` dict is probably the least invasive approach for the current code, or do you have another idea in mind that is better suited?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.