GitHubはじめる

このページはまだ日本語訳がないため、英語の原文を表示しています。

その他

Social

online/social holds the in-memory cores of a game service's social features, and online/realtime the notifications that carry them to players. Both are server-side code: a game client reaches them through the service that embeds them, and the service persists what it must keep.

Parties

social.Parties manages open parties, member limits, deterministic leader handover and pending queue state before matchmaking. A party created with a size below 1 holds 4 players; when the leader leaves, the member who joined earliest leads, and the last member to leave disbands the party. Any member joining or leaving clears the pending queue state, so the leader queues again with the new members.

Friends and blocks

social.Graph keeps friend invitations, friendships and blocks between accounts. AddFriend(a, b) invites b, or makes the two friends when b has already invited a; adding a friend or invitee again changes nothing. A block in either direction refuses it with ErrBlocked, and MaxFriends (on either side when accepting) or MaxPendingInvites with ErrLimit. RemoveFriend cancels, declines or ends a friendship on both sides. Block(a, b) records that a blocks b and removes any friendship or invitation between them; only Unblock(a, b) by the blocker lifts it, and Blocked reports a block in either direction. Friends(a, state) lists a's relations in one state, or all of them, sorted.

Groups

social.Groups holds groups with owner, admin, member, requested and banned roles. An open group admits an account that joins as a member, a closed one records it as requested, and joining again keeps an account's role. MaxMembers caps the owners, admins and members, not the requests. Only an owner or admin may Promote, and only a member to admin; the owner cannot leave its own group, a banned account cannot leave to lift its ban, and Search finds groups by a case-insensitive name prefix.

Chat

social.Chat keeps channel members and messages. ChannelID names a room, group or direct channel, sorting a direct channel's two accounts so both sides name the same channel. BeforeSend may rewrite or refuse a message before it is stored, as a moderation filter, MaxBytes caps a message's content, a group channel takes messages only from accounts that joined it and a DM channel only from its two accounts, Blocks refuses a DM when either account blocks the other, and Sweep drops messages older than Retention. A sender may Edit or Delete its own message; a deleted message keeps its place in History and HistoryBefore, which page backwards from a message ID.

Realtime notifications

online/realtime.Store models persistent and online-only notifications. Persistent notifications remain in history while offline, and online subscribers receive live events: Subscribe returns a buffered channel and a function that closes it, and a subscriber whose buffer is full misses the event rather than blocking the sender.

このページを編集