跳转至

GFNetworkLobbyOperationRequest

API Reference / Network / 类索引

  • 路径:addons/gf/extensions/network/session/gf_network_lobby_operation_request.gd
  • 模块:Network
  • 继承:RefCounted
  • API:public
  • 类别:事件契约 (event_contract)
  • 首次版本:unreleased

Lobby 操作请求。 将创建、查询、加入、离开和 metadata 更新统一为可关联、可复制的请求值对象。 Provider 专属参数只能放入 provider_options,不能泄漏到项目领域模型。

成员概览

类型 名称 签名
常量 OP_CREATE_LOBBY const OP_CREATE_LOBBY: StringName = &"create_lobby"
常量 OP_QUERY_LOBBIES const OP_QUERY_LOBBIES: StringName = &"query_lobbies"
常量 OP_JOIN_LOBBY const OP_JOIN_LOBBY: StringName = &"join_lobby"
常量 OP_LEAVE_LOBBY const OP_LEAVE_LOBBY: StringName = &"leave_lobby"
常量 OP_SET_LOBBY_METADATA const OP_SET_LOBBY_METADATA: StringName = &"set_lobby_metadata"
常量 OP_SET_MEMBER_METADATA const OP_SET_MEMBER_METADATA: StringName = &"set_member_metadata"
属性 request_id var request_id: StringName = &""
属性 operation var operation: StringName = &""
属性 lobby_id var lobby_id: String = ""
属性 peer_id var peer_id: int = 0
属性 query var query: GFNetworkLobbyQuery = null
属性 payload var payload: Dictionary = {}
属性 provider_options var provider_options: Dictionary = {}
属性 timeout_msec var timeout_msec: int = 0
属性 metadata var metadata: Dictionary = {}
方法 configure func configure( p_request_id: StringName, p_operation: StringName, options: Dictionary = {} ) -> GFNetworkLobbyOperationRequest:
方法 is_valid func is_valid() -> bool:
方法 to_dict func to_dict() -> Dictionary:
方法 apply_dict func apply_dict(data: Dictionary) -> void:
方法 duplicate_request func duplicate_request() -> GFNetworkLobbyOperationRequest:
方法 get_supported_operations static func get_supported_operations() -> PackedStringArray:
方法 from_dict static func from_dict(data: Dictionary) -> GFNetworkLobbyOperationRequest:

常量

OP_CREATE_LOBBY

  • API:public
  • 首次版本:unreleased
const OP_CREATE_LOBBY: StringName = &"create_lobby"

创建 Lobby 操作。

OP_QUERY_LOBBIES

  • API:public
  • 首次版本:unreleased
const OP_QUERY_LOBBIES: StringName = &"query_lobbies"

查询 Lobby 操作。

OP_JOIN_LOBBY

  • API:public
  • 首次版本:unreleased
const OP_JOIN_LOBBY: StringName = &"join_lobby"

加入 Lobby 操作。

OP_LEAVE_LOBBY

  • API:public
  • 首次版本:unreleased
const OP_LEAVE_LOBBY: StringName = &"leave_lobby"

离开 Lobby 操作。

OP_SET_LOBBY_METADATA

  • API:public
  • 首次版本:unreleased
const OP_SET_LOBBY_METADATA: StringName = &"set_lobby_metadata"

更新 Lobby metadata 操作。

OP_SET_MEMBER_METADATA

  • API:public
  • 首次版本:unreleased
const OP_SET_MEMBER_METADATA: StringName = &"set_member_metadata"

更新成员 metadata 操作。

属性

request_id

  • API:public
  • 首次版本:unreleased
var request_id: StringName = &""

请求稳定 ID。

operation

  • API:public
  • 首次版本:unreleased
var operation: StringName = &""

操作类型。

lobby_id

  • API:public
  • 首次版本:unreleased
var lobby_id: String = ""

目标 Lobby ID。

peer_id

  • API:public
  • 首次版本:unreleased
var peer_id: int = 0

目标成员 peer ID。

query

  • API:public
  • 首次版本:unreleased
var query: GFNetworkLobbyQuery = null

查询操作的过滤条件。

payload

  • API:public
  • 首次版本:unreleased
var payload: Dictionary = {}

操作载荷,例如 metadata patch。

结构:

  • payload: Dictionary operation payload.

provider_options

  • API:public
  • 首次版本:unreleased
var provider_options: Dictionary = {}

Provider 专属调用选项。

结构:

  • provider_options: Dictionary external provider options.

timeout_msec

  • API:public
  • 首次版本:unreleased
var timeout_msec: int = 0

超时时间,单位毫秒;0 表示由 Service 默认值决定或不限制。

metadata

  • API:public
  • 首次版本:unreleased
var metadata: Dictionary = {}

调用方元数据。

结构:

  • metadata: Dictionary caller-defined request metadata.

方法

configure

  • API:public
  • 首次版本:unreleased
func configure( p_request_id: StringName, p_operation: StringName, options: Dictionary = {} ) -> GFNetworkLobbyOperationRequest:

配置 Lobby 操作请求。

参数:

名称 说明
p_request_id 请求 ID。
p_operation 操作类型常量。
options 可包含 lobby_id、peer_id、query、payload、provider_options、timeout_msec 和 metadata。

返回:当前请求。

结构:

  • options: Dictionary lobby operation request fields.

is_valid

  • API:public
  • 首次版本:unreleased
func is_valid() -> bool:

检查请求字段是否满足对应操作的最小契约。

返回:请求可派发时返回 true。

to_dict

  • API:public
  • 首次版本:unreleased
func to_dict() -> Dictionary:

转换为字典。

返回:Lobby 操作请求字典。

结构:

  • return: Dictionary lobby operation request.

apply_dict

  • API:public
  • 首次版本:unreleased
func apply_dict(data: Dictionary) -> void:

从字典应用请求字段。

参数:

名称 说明
data Lobby 操作请求字典。

结构:

  • data: Dictionary lobby operation request.

duplicate_request

  • API:public
  • 首次版本:unreleased
func duplicate_request() -> GFNetworkLobbyOperationRequest:

创建请求深拷贝。

返回:新请求。

get_supported_operations

  • API:public
  • 首次版本:unreleased
static func get_supported_operations() -> PackedStringArray:

获取全部支持的操作 ID。

返回:固定操作 ID 集合。

from_dict

  • API:public
  • 首次版本:unreleased
static func from_dict(data: Dictionary) -> GFNetworkLobbyOperationRequest:

从字典创建请求。

参数:

名称 说明
data Lobby 操作请求字典。

返回:新请求。

结构:

  • data: Dictionary lobby operation request.