model

package
v0.0.0-...-211e82d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Name      string          // クライアント名
	SessionID string          // セッションID
	Ws        *websocket.Conn // WebSocket接続
}

Client はチャットルームに参加しているユーザーを表す構造体

type Message

type Message struct {
	RoomID    string `json:"room_id"`   // ルームID
	Sentence  string `json:"sentence"`  // メッセージ本文
	Sender    string `json:"sender"`    // 送信者
	Timestamp int64  `json:"timestamp"` // タイムスタンプ
}

Message はチャットメッセージを表す構造体

type Room

type Room struct {
	ID                     string     // ルームID
	Name                   string     // ルーム名
	Owner                  string     // ルームのオーナー
	Expires                time.Time  // 有効期限
	RequiresAuth           bool       // 認証が必要かどうか
	UnauthenticatedClients []*Client  // ルームへの接続許可待ちのクライアント
	AuthenticatedClients   []*Client  //ルームへの接続許可がされているクライアント
	Mu                     sync.Mutex // スレッドセーフにするためのミューテックス
}

Room は個々のチャットルームを表す構造体

type RoomManager

type RoomManager struct {
	Rooms           map[string]*Room // ルームのマップ
	ExpireSortRooms []*Room          // 期限順に並べたルーム
	Mu              sync.Mutex       // スレッドセーフにするためのミューテックス
}

RoomManager はチャットルーム全体の管理を行う構造体

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL