Class LobbyLoginController
This is in the LlamaSoftware.Chat.Demo namespace, indicating this is not a production-ready piece script. Instead it is meant to demonstrate how you may do something. A specialized LoginController to demonstrate how a lobby could work. Instead of automatically joining a lobby, you may want to split the logic here in your game with the login piece so a user can be put into a lobby instead of only having 1 lobby.
Inherited Members
Namespace: LlamaSoftware.Chat.Demo.Lobby
Assembly: LlamaSoftware.Chat.Demo.dll
Syntax
public class LobbyLoginController : LoginController
Fields
ChatPanelCanvas
Declaration
[SerializeField]
protected Canvas ChatPanelCanvas
Field Value
| Type | Description |
|---|---|
| UnityEngine.Canvas |
GameSceneName
Declaration
[SerializeField]
protected string GameSceneName
Field Value
| Type | Description |
|---|---|
| System.String |
LOBBY_PLAYERS_CHANNEL
Channel to send the Lobby Players network messages on.
Declaration
public const short LOBBY_PLAYERS_CHANNEL = 997
Field Value
| Type | Description |
|---|---|
| System.Int16 |
lobbyController
Declaration
[SerializeField]
protected LobbyController lobbyController
Field Value
| Type | Description |
|---|---|
| LobbyController |
LobbyPlayerPrefab
Declaration
[SerializeField]
[Tooltip("Must be registered under Network Manager as a Spawnable Prefab")]
protected Player_Chat LobbyPlayerPrefab
Field Value
| Type | Description |
|---|---|
| Player_Chat |
Players
Declaration
protected List<Player> Players
Field Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<Player> |
StartGameButton
Declaration
[SerializeField]
protected GameObject StartGameButton
Field Value
| Type | Description |
|---|---|
| UnityEngine.GameObject |
Methods
ClientHandleRegisterUser(NetworkMessage)
Repsonse handler for new user registration. If the message is not SUCCESS it is assumed to be an error.
Declaration
protected override void ClientHandleRegisterUser(NetworkMessage message)
Parameters
| Type | Name | Description |
|---|---|---|
| NetworkMessage | message | Network Message |
Overrides
ClientHandleUserLogin(NetworkMessage)
Handles response from user login. If the message is not SUCCESS it is assumed to be an error message.
Declaration
protected virtual void ClientHandleUserLogin(NetworkMessage message)
Parameters
| Type | Name | Description |
|---|---|---|
| NetworkMessage | message | Network Message |
ClientUpdateLobbyPlayers(NetworkMessage)
Response handler for Lobby user updates
Declaration
protected virtual void ClientUpdateLobbyPlayers(NetworkMessage message)
Parameters
| Type | Name | Description |
|---|---|---|
| NetworkMessage | message | Network message |
CreatePlayerFromRow(SqliteDataReader, NetworkMessage, Boolean)
Manually constructs a network player with Player_Chat player from the LobbyPlayerPrefab and pouplates from the provided Mono.Data.Sqlite.SqliteDataReader row.
Declaration
protected override void CreatePlayerFromRow(SqliteDataReader reader, NetworkMessage message, bool isCreateAccount)
Parameters
| Type | Name | Description |
|---|---|---|
| Mono.Data.Sqlite.SqliteDataReader | reader | |
| NetworkMessage | message | |
| System.Boolean | isCreateAccount |
Overrides
HandleRegisterUser(NetworkMessage)
Performs basic validation on the RegisterPlayerMessage request, if valid then inserts that information into the database and logs the user in. In your production application you would abstract this out to a singleton like AbstractPlayerDatabase<T>.
Declaration
protected override void HandleRegisterUser(NetworkMessage message)
Parameters
| Type | Name | Description |
|---|---|---|
| NetworkMessage | message | Network Message of type RegisterPlayerMessage. |
Overrides
HandleUserLogin(NetworkMessage)
Checks if the login is valid and creates the user. In your production application you would abstract this out to a singleton like AbstractPlayerDatabase<T>.
Declaration
protected override void HandleUserLogin(NetworkMessage message)
Parameters
| Type | Name | Description |
|---|---|---|
| NetworkMessage | message | Network Message of type LoginMessage. |
Overrides
OnStartClient()
Set up client network message handlers
Declaration
public override void OnStartClient()
Overrides
OnStartServer()
Set up server message handlers and Database connection
Declaration
public override void OnStartServer()
Overrides
StartGame()
Changes the scene on the
Declaration
public virtual void StartGame()
UpdatePlayers(IEnumerable<Player>)
Called by the LobbyNetworkManager when a player disconnects to ensure the list removes players who are no longer connected
Declaration
public virtual void UpdatePlayers(IEnumerable<Player> Players)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<Player> | Players | Collection of players still in the lobby |