Sign In Register

How can we help you today?

Start a new topic
Answered

Real-time matchmaking in Unity

Hi!

I'm trying to start real-time session in Unity. And i have two issues:

1. When i launch 2 copies of the game on the same Mac, i don't get "MatchFoundMessage" after calling MatchmakingRequest. I get the MatchmakingRequest response and it says HasErrors = false. If i try it with Unity copy of the app + Adobe AIR (as3) copy of the app on the same Mac - it works, i get the MatchFoundMessage! So what can be the point with 2 Unity copies? I start one copy using Terminal, second one in Unity.

2. I tried this on different computers. I launch one app copy on Window computer, second one in Unity on Mac. After MatchmakingRequest i get MatchFoundMessage. Host, Port, Token and MatchId are OK. So using this data i do:

 

	public void StartNewRTSession(RTSessionInfo rtSessionInfo)
	{
		Debug.Log ("GSM| Creating New RT Session Instance...");
		this.rtSessionInfo = rtSessionInfo;

		gameSparksRTUnity = this.gameObject.AddComponent<GameSparksRTUnity> ();

		GSRequestData mockedResponse = new GSRequestData ()
			.AddNumber ("port", (double)rtSessionInfo.GetPortId ())
			.AddString ("host", rtSessionInfo.GetHostURL ())
			.AddString ("accestoken", rtSessionInfo.GetAccessToken ());

		FindMatchResponse response = new FindMatchResponse (mockedResponse);

		gameSparksRTUnity.Configure (response,
			(peerId)=> { OnPlayerConnectedToGame(peerId); },
			(peerId) => { OnPlayerDisconnected(peerId); },
			(ready) => { OnRTReady(ready); },
			(packet) => { OnPacketReceived(packet); }
		);
		gameSparksRTUnity.Connect ();
	}

 and nothing happens. OnRTReady and OnPlayerConnectedToGame functions keep not called.


Best Answer

Hi Sean,

I found the cause of the problem. I wrote "accesstoken" word instead of "accessToken" when configuring RTSession. So it was my mistake. Thank you for trying help!


Thanks,

Rustam. 


No Problem Rustam.
Glad to hear it is working.

Sean

Answer

Hi Sean,

I found the cause of the problem. I wrote "accesstoken" word instead of "accessToken" when configuring RTSession. So it was my mistake. Thank you for trying help!


Thanks,

Rustam. 

Hey Rustam,


Sorry for the delay getting back to you.
There seems to be something wrong with the 'GameSparks' scene in that project link. I can open it in order to launch the game.
Could you try zipping it again and sending it on?

Thanks,
Sean

Any ideas?
Here is a simple test project https://goo.gl/oDm0GS
After initialization you can see a button that should find an opponent and start real-time session. But nothing happens after
gameSparksRTUnity.Connect ();

Rustam.

 

Hi Sean,
I get "Starting session", not "Seestion Started". As I can see this is debug log in GameSparksRTUnity.cs in Connect() method. After that i see no messages.

Rustam.
Hey Rustam,

If you get the 'Session Started' message you are good-to-go! The RT session is running.
The thing is that if you call the StartNewSession() method when you get the match found message you cant guarantee the other player will start at the same time as you.
You can code around that of course, but it looks to me like everything is working if you get the 'Session Started' message.

Sean

 

Hi Sean,

thank you for answers.

For [1]. Strange, but it works now. I'm using username/password authentication. Ok, it works and that's good.

For [2]. I'm doing my sample reading your RT demo. StartNewRTSession() is being called in onMatchFoundMessage() function. I want tot start the RT as soon as a match found. And as you can see in attached 1.jpg StartNewRTSession() works (i see debug message). After that i get another message "Starting session". And that's all. I added my LobbyManager and GameSparksManager to the zip.

Thanks!


zip
(359 KB)
Hey Rustam,

For issue [1], are you doing a device connect request? If this is the case, running two apps on the same machine would end up logging you in twice for the same player, so no new player would enter the match.
For the second issue, i would need more information. Do you have a script attached to the match that might be causing the match not to start? Could you send on the rest of the script so i can see that the callbacks are working correctly?

The other thing you could try is to setup the RT demo game and get that working, then work backwards from there. If i know that the demo is working correctly or not it gives me some place to start from.
I would also need to see where StartNewRTSession() is being called from.

Thanks,
Sean

 

Login to post a comment