ws

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// <summary>: プレイヤーの接続情報プール
	PlayerPool = NewPlayerMap()

	// <summary>: 部屋情報プール
	RoomPool = NewRoomMap()
)

Functions

func ChangeOutputDestination

func ChangeOutputDestination(dest io.Writer)

<summary>: ログの出力先を変更します <remark>: defaultは標準出力

func DisableColorLog

func DisableColorLog()

<summary>: ログの色つけを無効化します

func EnableColorLog

func EnableColorLog()

<summary>: ログの色つけを有効化します

func EntryPoint

func EntryPoint(w http.ResponseWriter, r *http.Request)

<summary>: WebSocket接続時に行われる動作

func ServeRequest

func ServeRequest()

<summary>: WebSocketでのリクエストを待ち受けます

Types

type PlayerConn

type PlayerConn struct {
	C      *websocket.Conn
	RoomId string
}

<summary>: プレイヤーの接続情報をまとめた構造体

type PlayerMap

type PlayerMap struct {
	// contains filtered or unexported fields
}

<summary>: プレイヤー情報向けスレッドセーフなデータ格納庫

func NewPlayerMap

func NewPlayerMap() *PlayerMap

<summary>: プレイヤー情報格納庫の初期化

func (*PlayerMap) Count

func (p *PlayerMap) Count() int

<summary>: プレイヤーマップにあるデータの数を数えます

func (*PlayerMap) Delete

func (p *PlayerMap) Delete(id string)

<summary>: プレイヤーマップから情報を削除します

func (*PlayerMap) Get

func (p *PlayerMap) Get(id string) (PlayerConn, bool)

<summary>: プレイヤーマップからキーをもとに情報を取得します

func (*PlayerMap) PlayerRoomData

func (p *PlayerMap) PlayerRoomData() map[string]string

<summary>: プレイヤーマップからプレイヤーがいる部屋情報の一覧を取得します

func (*PlayerMap) Set

func (p *PlayerMap) Set(id string, conn PlayerConn)

<summary>: プレイヤーマップに情報を格納します

func (*PlayerMap) SetRoomId

func (p *PlayerMap) SetRoomId(connid, roomid string) bool

<summary>: プレイヤーマップに部屋情報を上書きします <remark>: 上書きの成否が取得できます

type RoomMap

type RoomMap struct {
	// contains filtered or unexported fields
}

<summary>: 部屋情報向けスレッドセーフなデータ格納庫

func NewRoomMap

func NewRoomMap() *RoomMap

<summary>: 部屋情報格納庫の初期化

func (*RoomMap) Count

func (r *RoomMap) Count() int

<summary>: 部屋マップにあるデータの数を数えます

func (*RoomMap) Delete

func (r *RoomMap) Delete(id string)

<summary>: 部屋マップから情報を削除します

func (*RoomMap) Get

func (r *RoomMap) Get(id string) (models.RoomInfoSet, bool)

<summary>: 部屋マップからキーをもとに情報を取得します

func (*RoomMap) Range

func (r *RoomMap) Range(f func(id string, room models.RoomInfoSet))

<summary>: 部屋マップの情報に対して、一連の処理を実行します

func (*RoomMap) Set

func (r *RoomMap) Set(id string, room models.RoomInfoSet)

<summary>: 部屋マップに情報を格納します

Jump to

Keyboard shortcuts

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