コード例 #1
0
ファイル: NetworkManager.cs プロジェクト: leelnfei/Radius
    void OnConnectedToServer()
    {
        // Called on the client when you have successfully connected to a server.
        Debug.Log("You have Connected");

        // We are connected
        this.IsConnected = true;

        // Add yourself to the player list
        this.playerManager.GenerateSelf();

        // handle errors
        NetworkConnectionErrorResponse response = new NetworkConnectionErrorResponse();

        response.noErrorsYet      = true;
        response.ableToConnectYet = true;
        this.OnAsyncConnectInfoEvent(response);

        // Put the player in the game if the game is already going
        if (this.gameManager.GameStatus == GameManager.GameState.started)
        {
            this.playerManager.SpawnPlayer("self");
        }
    }
コード例 #2
0
ファイル: NetworkManager.cs プロジェクト: leelnfei/Radius
    public NetworkConnectionErrorResponse GetResponseFromNetworkConnectionError(NetworkConnectionError connectError)
    {
        NetworkConnectionErrorResponse response = new NetworkConnectionErrorResponse();
        string message = "";

        if (connectError == NetworkConnectionError.NoError)
        {
            message = "Connected to Server";
            response.noErrorsYet = true;
        }
        else if (connectError == NetworkConnectionError.RSAPublicKeyMismatch)
        {
            message = "RSA public key did not match what the system we connected to is using.";
        }
        else if (connectError == NetworkConnectionError.InvalidPassword)
        {
            message = "Invalid Password. Could not connect to server";
        }
        else if (connectError == NetworkConnectionError.ConnectionFailed)
        {
            message = "Could not connect to server";
        }
        else if (connectError == NetworkConnectionError.TooManyConnectedPlayers)
        {
            message = "Server Full. Could not connect to server";
        }
        else if (connectError == NetworkConnectionError.ConnectionBanned)
        {
            message = "You are banned from the system we attempted to connect to (likely temporarily).";
        }
        else if (connectError == NetworkConnectionError.AlreadyConnectedToServer)
        {
            message = "You are already connected to this particular server (can happen after fast disconnect/reconnect).";
        }
        else if (connectError == NetworkConnectionError.AlreadyConnectedToAnotherServer)
        {
            message = "Already Connected to a Server";
        }
        else if (connectError == NetworkConnectionError.CreateSocketOrThreadFailure)
        {
            message = "Internal error while attempting to initialize network interface. Socket possibly already in use.";
        }
        else if (connectError == NetworkConnectionError.IncorrectParameters)
        {
            message = "Incorrect parameters given to Connect function";
        }
        else if (connectError == NetworkConnectionError.EmptyConnectTarget)
        {
            message = "No host target given in Connect";
        }
        else if (connectError == NetworkConnectionError.InternalDirectConnectFailed)
        {
            message = "You could not connect internally to same network NAT enabled server.";
        }
        else if (connectError == NetworkConnectionError.NATTargetNotConnected)
        {
            message = "The NAT target you are trying to connect to is not connected to the facilitator server.";
        }
        else if (connectError == NetworkConnectionError.NATTargetConnectionLost)
        {
            message = "Connection lost while attempting to connect to NAT target.";
        }
        else if (connectError == NetworkConnectionError.NATPunchthroughFailed)
        {
            message = "NAT punchthrough attempt has failed. Could not connect to server";
        }

        response.message = message;

        return(response);
    }
コード例 #3
0
ファイル: NetworkManager.cs プロジェクト: SuperStarPL/Radius
	public NetworkConnectionErrorResponse GetResponseFromNetworkConnectionError(NetworkConnectionError connectError)
	{
		NetworkConnectionErrorResponse response = new NetworkConnectionErrorResponse();
		string message = "";

		if(connectError == NetworkConnectionError.NoError) {
			message = "Connected to Server";
			response.noErrorsYet = true;
		}
		else if(connectError == NetworkConnectionError.RSAPublicKeyMismatch) {
			message = "RSA public key did not match what the system we connected to is using.";
		}
		else if(connectError == NetworkConnectionError.InvalidPassword) {
			message = "Invalid Password. Could not connect to server";
		}
		else if(connectError == NetworkConnectionError.ConnectionFailed) {
			message = "Could not connect to server";
		}
		else if(connectError == NetworkConnectionError.TooManyConnectedPlayers) {
			message = "Server Full. Could not connect to server";
		}
		else if(connectError == NetworkConnectionError.ConnectionBanned) {
			message = "You are banned from the system we attempted to connect to (likely temporarily).";
		}
		else if(connectError == NetworkConnectionError.AlreadyConnectedToServer) {
			message = "You are already connected to this particular server (can happen after fast disconnect/reconnect).";
		}
		else if(connectError == NetworkConnectionError.AlreadyConnectedToAnotherServer) {
			message = "Already Connected to a Server";
		}
		else if(connectError == NetworkConnectionError.CreateSocketOrThreadFailure) {
			message = "Internal error while attempting to initialize network interface. Socket possibly already in use.";
		}
		else if(connectError == NetworkConnectionError.IncorrectParameters) {
			message = "Incorrect parameters given to Connect function";
		}
		else if(connectError == NetworkConnectionError.EmptyConnectTarget) {
			message = "No host target given in Connect";
		}
		else if(connectError == NetworkConnectionError.InternalDirectConnectFailed) {
			message = "You could not connect internally to same network NAT enabled server.";
		}
		else if(connectError == NetworkConnectionError.NATTargetNotConnected) {
			message = "The NAT target you are trying to connect to is not connected to the facilitator server.";
		}
		else if(connectError == NetworkConnectionError.NATTargetConnectionLost) {
			message = "Connection lost while attempting to connect to NAT target.";
		}
		else if(connectError == NetworkConnectionError.NATPunchthroughFailed) {
			message = "NAT punchthrough attempt has failed. Could not connect to server";
		}

		response.message = message;

		return response;
	}
コード例 #4
0
ファイル: NetworkManager.cs プロジェクト: SuperStarPL/Radius
	void OnConnectedToServer()
	{
		// Called on the client when you have successfully connected to a server.
		Debug.Log("You have Connected");

		// We are connected
		this.IsConnected = true;

		// Add yourself to the player list
		this.playerManager.GenerateSelf();

		// handle errors
		NetworkConnectionErrorResponse response = new NetworkConnectionErrorResponse();
		response.noErrorsYet = true;
		response.ableToConnectYet = true;
		this.OnAsyncConnectInfoEvent(response);

		// Put the player in the game if the game is already going
		if(this.gameManager.GameStatus == GameManager.GameState.started)
			this.playerManager.SpawnPlayer("self");
	}