Exemplo n.º 1
0
        // -------------------------------------------------------------------------------
        // OnClientMessageRequestPlayerRegister
        // @Client -> @Server
        // -------------------------------------------------------------------------------
        /// <summary>
        /// Event <c>OnClientMessageRequestPlayerRegister</c>.
        /// Triggered by the server receiving a player regstration request from the client.
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="msg"></param>
        void OnClientMessageRequestPlayerRegister(NetworkConnection conn, ClientMessageRequestPlayerRegister msg)
        {
            ServerMessageResponsePlayerRegister message = new ServerMessageResponsePlayerRegister
            {
                success          = true,
                text             = "",
                causesDisconnect = false,
                playername       = msg.playername
            };

            if (DatabaseManager.singleton.TryPlayerRegister(msg.playername, msg.username, msg.prefabname))
            {
                RegisterPlayer(msg.username, msg.playername, msg.prefabname);
                message.text = systemText.playerRegisterSuccess;
            }
            else
            {
                message.text    = systemText.playerRegisterFailure;
                message.success = false;

                debug.LogFormat(this.name, nameof(OnClientMessageRequestPlayerRegister), conn.Id(), "DENIED");                 //DEBUG
            }

            conn.Send(message);
        }
Exemplo n.º 2
0
        // -------------------------------------------------------------------------------
        /// <summary>
        /// Event <c>OnServerMessageResponsePlayerRegister</c>.
        /// Triggered when the client receives a player register response from the server.
        /// Triggers the <c>OnServerMessageResponse</c> event.
        /// Occurs on the client.
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="msg"></param>
        void OnServerMessageResponsePlayerRegister(NetworkConnection conn, ServerMessageResponsePlayerRegister msg)
        {
            if (msg.success)
            {
                playerPreviews.Add(new PlayerPreview {
                    name = msg.playername
                });
                UIWindowPlayerSelect.singleton.UpdatePlayerPreviews(true);
            }

            OnServerMessageResponse(conn, msg);
        }
Exemplo n.º 3
0
        // -------------------------------------------------------------------------------
        /// <summary>
        /// Event <c>OnServerMessageResponsePlayerRegister</c>.
        /// Triggered when the client receives a player register response from the server.
        /// Triggers the <c>OnServerMessageResponse</c> event.
        /// Occurs on the client.
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="msg"></param>
        void OnServerMessageResponsePlayerRegister(NetworkConnection conn, ServerMessageResponsePlayerRegister msg)
        {
            if (msg.success)
            {
                playerPreviews.Add(new PlayerPreview {
                    name = msg.playername
                });
                UIWindowPlayerSelect.singleton.UpdatePlayerPreviews(true);
            }

            debug.LogFormat(this.name, nameof(OnServerMessageResponsePlayerRegister), conn.Id(), msg.success.ToString());     //DEBUG

            OnServerMessageResponse(conn, msg);
        }
Exemplo n.º 4
0
        // -------------------------------------------------------------------------------
        // OnClientMessageRequestPlayerRegister
        // @Client -> @Server
        // -------------------------------------------------------------------------------
        void OnClientMessageRequestPlayerRegister(NetworkConnection conn, ClientMessageRequestPlayerRegister msg)
        {
            ServerMessageResponsePlayerRegister message = new ServerMessageResponsePlayerRegister
            {
                success          = true,
                text             = "",
                causesDisconnect = false
            };

            if (DatabaseManager.singleton.TryPlayerRegister(msg.playername, msg.username, msg.prefabname))
            {
                RegisterPlayer(msg.username, msg.playername, msg.prefabname);
                message.text = systemText.playerRegisterSuccess;
            }
            else
            {
                message.text    = systemText.playerRegisterFailure;
                message.success = false;
            }

            conn.Send(message);
        }
Exemplo n.º 5
0
 // -------------------------------------------------------------------------------
 void OnServerMessageResponsePlayerRegister(NetworkConnection conn, ServerMessageResponsePlayerRegister msg)
 {
     OnServerMessageResponse(conn, msg);
 }