O'Reilly logo

Unity Multiplayer Games by Alan Stagner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting a list of rooms

Now that we're connected to Player.IO, and to our local server, we can get a list of rooms.

using UnityEngine;
using System.Collections;

using PlayerIOClient;

public class ConnectToPlayerIO : MonoBehaviour
{
  public bool UseDevServer = true;

  Client client;

  void Start()
  {
    PlayerIO.UnityInit( this );

    PlayerIO.Connect( "YourGameIDHere", "public", "YourUserIDHere", null, null,
    delegate( Client c )
    {
      // connected successfully
      client = c;
      Debug.Log( "Connected" );

      // if we're using the dev server, connect to the local IP
      if( UseDevServer )
      {
        client.Multiplayer.DevelopmentServer = new ServerEndpoint( "127.0.0.1", 8184 );
        GetRoomList(); } }, delegate( PlayerIOError error ) { // did not connect successfully Debug.Log( error.Message ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required