Documentation
¶
Overview ¶
Package streaming provides the WebSocket /streaming endpoint that Misskey clients connect to for live timeline / notification updates.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionAcceptor ¶
type ConnectionAcceptor interface {
Accept(conn *websocket.Conn, user *model.User, scopes []string, credential string)
}
ConnectionAcceptor receives an upgraded WebSocket connection, an optional authenticated user, and the OAuth2 scopes the connection is limited to. パッケージ間の循環依存を避けるため interface で受け取る (実装は internal/stream の Manager)。
scopes は **app access_token のときだけ non-nil**。nil は「スコープによる 制限が無い」を意味し、native login token (フロントエンドが使う) と 匿名接続がそちらに当たる。mk-go は cookie 認証を持たない。空の non-nil slice は「スコープを 1 つも持たない app token」で、 nil とは区別する。
credential は認証に使った資格情報の鍵 (internal/misc/credkey)。匿名は ""。 トークンが失効したときに、そのトークンで張られた接続だけを閉じるのに使う。
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler upgrades incoming HTTP requests to a WebSocket and hands the resulting connection to a ConnectionAcceptor. 認証はミドルウェア (RequireAuth ではなく Authenticate のみ) でベストエフォートに行い、未認証接続も許容する。
func NewHandler ¶
func NewHandler(acceptor ConnectionAcceptor) *Handler
NewHandler constructs a Handler. acceptor が nil の場合、upgrade 直後に 接続を閉じる (テスト用)。