LeanCloud C# SDK
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Properties | List of all members
LeanCloud.Play.Client Class Reference

客户端类 More...

Public Member Functions

 Client (string appId, string appKey, string userId, bool ssl=true, string gameVersion="0.0.1", string playServer=null)
 Client 构造方法
 
async Task< ClientConnect ()
 连接
 
async Task JoinLobby ()
 加入大厅,会接收到大厅房间列表更新的事件
 
async Task LeaveLobby ()
 离开大厅
 
async Task< RoomCreateRoom (string roomName=null, RoomOptions roomOptions=null, List< string > expectedUserIds=null)
 创建房间
 
async Task< RoomJoinRoom (string roomName, List< string > expectedUserIds=null)
 加入房间
 
async Task< RoomRejoinRoom (string roomName)
 返回房间
 
async Task< RoomJoinOrCreateRoom (string roomName, RoomOptions roomOptions=null, List< string > expectedUserIds=null)
 加入或创建房间,如果房间 Id 存在,则加入;否则根据 roomOptions 和 expectedUserIds 创建新的房间
 
async Task< RoomJoinRandomRoom (PlayObject matchProperties=null, List< string > expectedUserIds=null)
 随机加入房间
 
async Task< RoomReconnectAndRejoin ()
 重连并返回上一个加入的房间
 
async Task< string > MatchRandom (string piggybackUserId, PlayObject matchProperties=null, List< string > expectedUserIds=null)
 匹配房间(不加入)
 
async Task LeaveRoom ()
 离开房间
 
async Task< string > FetchMyRoom ()
 获取玩家当前房间
 
async Task< bool > SetRoomOpen (bool open)
 设置房间开启 / 关闭
 
async Task< bool > SetRoomVisible (bool visible)
 设置房间可见性
 
async Task< int > SetRoomMaxPlayerCount (int count)
 设置房间最大玩家数量
 
async Task< List< string > > SetRoomExpectedUserIds (List< string > expectedUserIds)
 设置期望用户
 
async Task ClearRoomExpectedUserIds ()
 清空期望用户 Id 列表
 
async Task< List< string > > AddRoomExpectedUserIds (List< string > expectedUserIds)
 增加期望用户
 
async Task< List< string > > RemoveRoomExpectedUserIds (List< string > expectedUserIds)
 删除期望用户
 
async Task< PlayerSetMaster (int newMasterId)
 设置房主
 
async Task KickPlayer (int actorId, int code=0, string reason=null)
 将玩家踢出房间
 
Task SendEvent (byte eventId, PlayObject eventData=null, SendEventOptions options=null)
 发送自定义事件
 
async Task SetRoomCustomProperties (PlayObject properties, PlayObject expectedValues=null)
 设置房间自定义属性
 
async Task SetPlayerCustomProperties (int actorId, PlayObject properties, PlayObject expectedValues=null)
 设置玩家自定义属性
 
void PauseMessageQueue ()
 暂停消息队列
 
void ResumeMessageQueue ()
 恢复消息队列
 
async Task Close ()
 关闭服务
 

Public Attributes

Action< List< LobbyRoom > > OnLobbyRoomListUpdated
 大厅房间列表更新事件
 
Action< PlayerOnPlayerRoomJoined
 有玩家加入房间事件
 
Action< PlayerOnPlayerRoomLeft
 有玩家离开房间事件
 
Action< PlayerOnMasterSwitched
 房主切换事件
 
Action< PlayObjectOnRoomCustomPropertiesChanged
 房间自定义属性更新事件
 
Action< PlayObjectOnRoomSystemPropertiesChanged
 房间系统属性更新事件,目前包括:房间开关,可见性,最大玩家数量,预留玩家 Id 列表
 
Action< Player, PlayObjectOnPlayerCustomPropertiesChanged
 玩家自定义属性更新事件
 
Action< PlayerOnPlayerActivityChanged
 玩家在线 / 离线变化事件
 
Action< byte, PlayObject, int > OnCustomEvent
 用户自定义事件
 
Action< int?, string > OnRoomKicked
 被踢出房间事件
 
Action OnDisconnected
 断线事件
 
Action< int, string > OnError
 错误事件
 

Properties

string PlayServer [get]
 
string AppId [get]
 LeanCloud App Id.
 
string AppKey [get]
 LeanCloud App Key.
 
string UserId [get]
 用户唯一 Id
 
bool Ssl [get]
 是否启用 SSL
 
string GameVersion [get]
 客户端版本号,不同的版本号的玩家不会匹配到相同的房间
 
List< LobbyRoomLobbyRoomList [get]
 大厅房间列表
 
Room Room [get, set]
 当前房间对象
 
Player Player [get]
 当前玩家对象
 

Detailed Description

客户端类

Constructor & Destructor Documentation

◆ Client()

LeanCloud.Play.Client.Client ( string  appId,
string  appKey,
string  userId,
bool  ssl = true,
string  gameVersion = "0.0.1",
string  playServer = null 
)
inline

Client 构造方法

Parameters
appIdLeanCloud App Id
appKeyLeanCloud App Key
userId用户唯一 Id
ssl是否启用 SSL
gameVersion游戏版本号
playServer游戏服务器地址

Member Function Documentation

◆ AddRoomExpectedUserIds()

async Task< List< string > > LeanCloud.Play.Client.AddRoomExpectedUserIds ( List< string >  expectedUserIds)
inline

增加期望用户

Returns
房间当前期望加入玩家列表
Parameters
expectedUserIds增加的期望用户 Id 列表

◆ ClearRoomExpectedUserIds()

async Task LeanCloud.Play.Client.ClearRoomExpectedUserIds ( )
inline

清空期望用户 Id 列表

◆ Close()

async Task LeanCloud.Play.Client.Close ( )
inline

关闭服务

◆ Connect()

async Task< Client > LeanCloud.Play.Client.Connect ( )
inline

连接

Returns
客户端

◆ CreateRoom()

async Task< Room > LeanCloud.Play.Client.CreateRoom ( string  roomName = null,
RoomOptions  roomOptions = null,
List< string >  expectedUserIds = null 
)
inline

创建房间

Parameters
roomName房间唯一 Id
roomOptions创建房间选项
expectedUserIds期望用户 Id 列表
Returns
房间

◆ FetchMyRoom()

async Task< string > LeanCloud.Play.Client.FetchMyRoom ( )
inline

获取玩家当前房间

Returns
房间 id

◆ JoinLobby()

async Task LeanCloud.Play.Client.JoinLobby ( )
inline

加入大厅,会接收到大厅房间列表更新的事件

◆ JoinOrCreateRoom()

async Task< Room > LeanCloud.Play.Client.JoinOrCreateRoom ( string  roomName,
RoomOptions  roomOptions = null,
List< string >  expectedUserIds = null 
)
inline

加入或创建房间,如果房间 Id 存在,则加入;否则根据 roomOptions 和 expectedUserIds 创建新的房间

Parameters
roomName房间 Id
roomOptions创建房间选项
expectedUserIds期望用户 Id 列表
Returns
房间

◆ JoinRandomRoom()

async Task< Room > LeanCloud.Play.Client.JoinRandomRoom ( PlayObject  matchProperties = null,
List< string >  expectedUserIds = null 
)
inline

随机加入房间

Parameters
matchProperties匹配属性
expectedUserIds期望用户 Id 列表
Returns
房间

◆ JoinRoom()

async Task< Room > LeanCloud.Play.Client.JoinRoom ( string  roomName,
List< string >  expectedUserIds = null 
)
inline

加入房间

Parameters
roomName房间 Id
expectedUserIds期望用户 Id 列表
Returns
房间

◆ KickPlayer()

async Task LeanCloud.Play.Client.KickPlayer ( int  actorId,
int  code = 0,
string  reason = null 
)
inline

将玩家踢出房间

Parameters
actorId玩家的 Actor Id
code附加码
reason附加消息

◆ LeaveLobby()

async Task LeanCloud.Play.Client.LeaveLobby ( )
inline

离开大厅

◆ LeaveRoom()

async Task LeanCloud.Play.Client.LeaveRoom ( )
inline

离开房间

◆ MatchRandom()

async Task< string > LeanCloud.Play.Client.MatchRandom ( string  piggybackUserId,
PlayObject  matchProperties = null,
List< string >  expectedUserIds = null 
)
inline

匹配房间(不加入)

Parameters
piggybackUserId占位用户 Id
matchProperties匹配属性
Returns
房间 Id

◆ PauseMessageQueue()

void LeanCloud.Play.Client.PauseMessageQueue ( )
inline

暂停消息队列

◆ ReconnectAndRejoin()

async Task< Room > LeanCloud.Play.Client.ReconnectAndRejoin ( )
inline

重连并返回上一个加入的房间

Returns
房间

◆ RejoinRoom()

async Task< Room > LeanCloud.Play.Client.RejoinRoom ( string  roomName)
inline

返回房间

Parameters
roomName房间 Id
Returns
房间

◆ RemoveRoomExpectedUserIds()

async Task< List< string > > LeanCloud.Play.Client.RemoveRoomExpectedUserIds ( List< string >  expectedUserIds)
inline

删除期望用户

Returns
房间当前期望加入玩家列表
Parameters
expectedUserIds删除的期望用户 Id 列表

◆ ResumeMessageQueue()

void LeanCloud.Play.Client.ResumeMessageQueue ( )
inline

恢复消息队列

◆ SendEvent()

Task LeanCloud.Play.Client.SendEvent ( byte  eventId,
PlayObject  eventData = null,
SendEventOptions  options = null 
)
inline

发送自定义事件

Parameters
eventId事件 Id
eventData事件参数
options事件选项

◆ SetMaster()

async Task< Player > LeanCloud.Play.Client.SetMaster ( int  newMasterId)
inline

设置房主

Returns
房主
Parameters
newMasterId新房主的 Actor Id

◆ SetPlayerCustomProperties()

async Task LeanCloud.Play.Client.SetPlayerCustomProperties ( int  actorId,
PlayObject  properties,
PlayObject  expectedValues = null 
)
inline

设置玩家自定义属性

Parameters
actorId玩家 Actor Id
properties自定义属性
expectedValues用于 CAS 的期望属性

◆ SetRoomCustomProperties()

async Task LeanCloud.Play.Client.SetRoomCustomProperties ( PlayObject  properties,
PlayObject  expectedValues = null 
)
inline

设置房间自定义属性

Parameters
properties自定义属性
expectedValues用于 CAS 的期望属性

◆ SetRoomExpectedUserIds()

async Task< List< string > > LeanCloud.Play.Client.SetRoomExpectedUserIds ( List< string >  expectedUserIds)
inline

设置期望用户

Returns
房间当前期望加入玩家列表
Parameters
expectedUserIds期望用户 Id 列表

◆ SetRoomMaxPlayerCount()

async Task< int > LeanCloud.Play.Client.SetRoomMaxPlayerCount ( int  count)
inline

设置房间最大玩家数量

Returns
房间可容纳的最大人数
Parameters
count数量

◆ SetRoomOpen()

async Task< bool > LeanCloud.Play.Client.SetRoomOpen ( bool  open)
inline

设置房间开启 / 关闭

Returns
房间是否开启
Parameters
open是否开启

◆ SetRoomVisible()

async Task< bool > LeanCloud.Play.Client.SetRoomVisible ( bool  visible)
inline

设置房间可见性

Returns
房间是否可见
Parameters
visible是否可见

Member Data Documentation

◆ OnCustomEvent

Action<byte, PlayObject, int> LeanCloud.Play.Client.OnCustomEvent

用户自定义事件

◆ OnDisconnected

Action LeanCloud.Play.Client.OnDisconnected

断线事件

◆ OnError

Action<int, string> LeanCloud.Play.Client.OnError

错误事件

◆ OnLobbyRoomListUpdated

Action<List<LobbyRoom> > LeanCloud.Play.Client.OnLobbyRoomListUpdated

大厅房间列表更新事件

◆ OnMasterSwitched

Action<Player> LeanCloud.Play.Client.OnMasterSwitched

房主切换事件

◆ OnPlayerActivityChanged

Action<Player> LeanCloud.Play.Client.OnPlayerActivityChanged

玩家在线 / 离线变化事件

◆ OnPlayerCustomPropertiesChanged

Action<Player, PlayObject> LeanCloud.Play.Client.OnPlayerCustomPropertiesChanged

玩家自定义属性更新事件

◆ OnPlayerRoomJoined

Action<Player> LeanCloud.Play.Client.OnPlayerRoomJoined

有玩家加入房间事件

◆ OnPlayerRoomLeft

Action<Player> LeanCloud.Play.Client.OnPlayerRoomLeft

有玩家离开房间事件

◆ OnRoomCustomPropertiesChanged

Action<PlayObject> LeanCloud.Play.Client.OnRoomCustomPropertiesChanged

房间自定义属性更新事件

◆ OnRoomKicked

Action<int?, string> LeanCloud.Play.Client.OnRoomKicked

被踢出房间事件

◆ OnRoomSystemPropertiesChanged

Action<PlayObject> LeanCloud.Play.Client.OnRoomSystemPropertiesChanged

房间系统属性更新事件,目前包括:房间开关,可见性,最大玩家数量,预留玩家 Id 列表

Property Documentation

◆ AppId

string LeanCloud.Play.Client.AppId
get

LeanCloud App Id.

App Id

◆ AppKey

string LeanCloud.Play.Client.AppKey
get

LeanCloud App Key.

App Key

◆ GameVersion

string LeanCloud.Play.Client.GameVersion
get

客户端版本号,不同的版本号的玩家不会匹配到相同的房间

游戏版本号

◆ LobbyRoomList

List<LobbyRoom> LeanCloud.Play.Client.LobbyRoomList
get

大厅房间列表

可加入的房间列表

◆ Player

Player LeanCloud.Play.Client.Player
get

当前玩家对象

当前玩家

◆ PlayServer

string LeanCloud.Play.Client.PlayServer
get

◆ Room

Room LeanCloud.Play.Client.Room
getset

当前房间对象

当前房间

◆ Ssl

bool LeanCloud.Play.Client.Ssl
get

是否启用 SSL

如果开启 SSL,则设为 true;否则设为 false。默认是 true

◆ UserId

string LeanCloud.Play.Client.UserId
get

用户唯一 Id

玩家唯一 Id


The documentation for this class was generated from the following file: