The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on Fusion.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Matchmaking doesn't work Photon Fusion

kroko
2022-04-01 07:51:37

Im trying to make a simple room system in photon fusion. However I ran into a problem, when I try to start a client after joining a session i get an error.

Here is the object that handles all of the matchmaking.

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using Fusion;

using TMPro;

using Fusion.Sockets;

using System;

public class Connecting : MonoBehaviour, INetworkRunnerCallbacks

{

public void OnPlayerJoined(NetworkRunner runner, PlayerRef player)

{

Debug.Log("a new Player");

}

public void OnPlayerLeft(NetworkRunner runner, PlayerRef player) { }

public void OnInput(NetworkRunner runner, NetworkInput input) { }

public void OnInputMissing(NetworkRunner runner, PlayerRef player, NetworkInput input) { }

public void OnShutdown(NetworkRunner runner, ShutdownReason shutdownReason) { }

public void OnConnectedToServer(NetworkRunner runner) { }

public void OnDisconnectedFromServer(NetworkRunner runner) { }

public void OnConnectRequest(NetworkRunner runner, NetworkRunnerCallbackArgs.ConnectRequest request, byte[] token) { }

public void OnConnectFailed(NetworkRunner runner, NetAddress remoteAddress, NetConnectFailedReason reason) { }

public void OnUserSimulationMessage(NetworkRunner runner, SimulationMessagePtr message) { }

public void OnSessionListUpdated(NetworkRunner runner, List sessionList) { }

public void OnCustomAuthenticationResponse(NetworkRunner runner, Dictionary<string, object> data) { }

public void OnHostMigration(NetworkRunner runner, HostMigrationToken hostMigrationToken) { }

public void OnReliableDataReceived(NetworkRunner runner, PlayerRef player, ArraySegment data) { }

public void OnSceneLoadDone(NetworkRunner runner) { }

public void OnSceneLoadStart(NetworkRunner runner) { }

public string roomID;

public TMP_InputField startInput;

public TMP_InputField joinInput;

public TMP_InputField NickNameInput;

bool nickProvided = false;

public string nick;

private string randomNick;

// Start is called before the first frame update

void Start()

{

DontDestroyOnLoad(gameObject);

randomNick = UnityEngine.Random.Range(1f, 99f).ToString();

}

private void Update()

{

if (NickNameInput.text == ""|| NickNameInput.textnull || NickNameInput.text " ")

{

nickProvided = false;

}

else

{

nickProvided = true;

}

if (nickProvided == false)

{

nick = randomNick;

}

//NickName

nick = NickNameInput.text;

}

public void StartHost(NetworkRunner runner)

{

runner.StartGame(new StartGameArgs()

{

GameMode = GameMode.Host,

SessionName = startInput.text,

CustomLobbyName = startInput.text

});

Debug.Log(runner.SessionInfo.PlayerCount);

Debug.Log(runner.SessionInfo.Name);

Debug.Log(runner.SessionInfo.IsValid);

Debug.Log(runner.SessionInfo.IsOpen);

}

public void JoinLobby(NetworkRunner runner)

{

runner.JoinSessionLobby(SessionLobby.Custom, joinInput.text);

runner.StartGame(new StartGameArgs()

{

GameMode = GameMode.Client,

SessionName = runner.SessionInfo.Name

});

Debug.Log(runner.SessionInfo.Name);

}

}

Here is all the code im using to handle matchmaking.

The game works fine when I try to host a game however when I try to join the same game from the build i get an error. I also get the same error even if the room im trying to join doesnt exist. The error occures as soon as it read this

runner.StartGame(new StartGameArgs()

{

GameMode = GameMode.Client,

SessionName = runner.SessionInfo.Name

});

Pls help

Comments

Isaac_Augusto
2022-04-01 15:07:55

Hi,

SessionName = runner.SessionInfo.Name

Should not be valid, because you haven't started your runner yet , so it doesn't have a SessionInfo to look at.

Have you already take a look at our samples and Fusion 100 tutorial series?

Fusion 102 (Basic setup for host) -> https://doc.photonengine.com/en-us/fusion/current/fusion-100/fusion-102

Application loop Sample -> https://doc.photonengine.com/en-us/fusion/current/samples/fusion-application-loop

Matchmaking API -> https://doc.photonengine.com/en-US/fusion/current/manual/matchmaking

--

Isaac Augusto

Photon Fusion Team

kroko
2022-04-02 09:14:32

Isaac_Augusto 2022-04-01T15:07:55+00:00

Hi,

SessionName = runner.SessionInfo.Name

Should not be valid, because you haven't started your runner yet , so it doesn't have a SessionInfo to look at.

Have you already take a look at our samples and Fusion 100 tutorial series?

Fusion 102 (Basic setup for host) -> https://doc.photonengine.com/en-us/fusion/current/fusion-100/fusion-102

Application loop Sample -> https://doc.photonengine.com/en-us/fusion/current/samples/fusion-application-loop

Matchmaking API -> https://doc.photonengine.com/en-US/fusion/current/manual/matchmaking

--

Isaac Augusto

Photon Fusion Team

At first I thought this didn't solve my problem since I already tried replacing

SessionName = runner.SessionInfo.Name

with a fixed string and that didn't help since I was getting the same error. But of all the three links you provided I realized that I haven't visited the Fusion 102 (Basic setup for host), and there I found the solution!

Thank you for your help!

Back to top