コード例 #1
0
        // -------------------------------------------------------------------------------
        // RequestSwitchServerPlayer
        // -------------------------------------------------------------------------------
        public override bool RequestSwitchServerPlayer(NetworkConnection conn, string name, int _token = 0)
        {
            _token = Tools.GenerateToken();

            if (!base.RequestSwitchServerPlayer(conn, name, _token))
            {
                return(false);
            }

            PlayerSwitchServerRequestMessage message = new PlayerSwitchServerRequestMessage
            {
                username = name,
                token    = _token
            };

            conn.Send(message);

            return(true);
        }
コード例 #2
0
        // -------------------------------------------------------------------------------
        // OnPlayerSwitchServerRequestMessage
        // @Client -> @Server
        // -------------------------------------------------------------------------------
        void OnPlayerSwitchServerRequestMessage(NetworkConnection conn, PlayerSwitchServerRequestMessage msg)
        {
            ServerResponseMessage message = new ServerResponseMessage
            {
                code             = successCode,
                text             = "",
                causesDisconnect = false
            };

            if (DatabaseManager.singleton.TryPlayerSwitchServer(msg.username, msg.token))
            {
                message.text = systemText.playerSwitchServerSuccess;
                eventListener.onPlayerSwitchServer.Invoke(msg.username);
            }
            else
            {
                message.text = systemText.playerSwitchServerFailure;
                message.code = errorCode;
            }

            conn.Send(message);
        }