- Code: Select all
void ConnectToNetwork()
{
//PlayerIO.UseSecureApiRequests = true;
PlayerIO.Authenticate
(
"hidden",
"public",
new Dictionary<string, string> { { "userId", _localPlayerName } },
null,
delegate (Client client)
{
//Debug.Log("Successfully connected to Player.IO");
// Comment out the line below to use the live servers instead of your development server
client.Multiplayer.DevelopmentServer = new ServerEndpoint("hidden", 8184);
//client.Multiplayer.UseSecureConnections = true;
//Debug.Log("CreateJoinRoom");
//Create or join the room
client.Multiplayer.CreateJoinRoom(_roomName, "DwarvenArenaMatchServer", false, new Dictionary<string, string> { { "privateGame", "true" } }, null,
delegate (Connection connection)
{
//Debug.Log("Joined Room.");
_pio = connection;
_pio.OnMessage += HandleMessage;
_joinedRoom = true;
},
delegate (PlayerIOError error)
{
ErrorMessageController.Instance.ShowError("Failed to join! WTF, dude? " + error.ToString(), true);
Debug.Log("Error Joining Room: " + error.ToString());
}
);
},
delegate (PlayerIOError error)
{
ErrorMessageController.Instance.ShowError("Failed to connect! WTF, dude? " + error.ToString(), true);
Debug.Log("Error connecting: " + error.ToString());
}
);
}