I am developing a basic MMORPG using Unity engine. I need a simple solution (library, framework) to make an efficient server. What is the best way to accomplish this task?
Original post is here.
You might try SmartFox, this link might be a good start for you. Below tutorials are also helpful for a quick start:
Specifically, you can connect to the smartfox server and get notified on connection:
private SmartFox client;
private string serverIP = "127.0.0.1";
private int serverPort = 9933;
private string zone = "BasicExamples";
client = new SmartFox();
client.ThreadSafeMode = false; //true for Unity3D
client.AddEventListener(SFSEvent.CONNECTION, (evt) =>
{
bool bSuccess = (bool)evt.Params[“success”];
Console.WriteLine(client.IsConnected ?
“Successfully connected to SmartFox Server” :
“Failed to connect to SmartFox Server”);
});
client.Connect(serverIP, serverPort);
To Login and get hooked when login succeeds:
var request = new LoginRequest("UserName", "Password", zone); //[1]
client.Send(request); //[2]
client.AddEventListener(SFSEvent.LOGIN, (evt) => { //[3]
Console.WriteLine("The User login success");
});
client.Connect(serverIP, serverPort);
2. Photon is another popular backend server/service.
Photon Server provides you with turnkey frameworks for multiplayer games. Start from scratch or build your own custom logic on top of several demo applications included in source code with the free server SDKs. This lets you achieve great results fast and easy.
Code snippet for setup connection:
using UnityEngine;
public class RandomMatchmaker : MonoBehaviour
{
void Start() {
PhotonNetwork.ConnectUsingSettings("0.1");
}
void OnGUI(){
GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
}
}
Code snippet for join room/lobby:
public override void OnJoinedLobby()
{
PhotonNetwork.JoinRandomRoom();
}
Code snippet for setup logging:
PhotonNetwork.logLevel = PhotonLogLevel.Full;
Code snippet for error handling:
void OnPhotonRandomJoinFailed()
{
Debug.Log("Can't join random room!");
PhotonNetwork.CreateRoom(null);
}
A good tutorial on this topic can be found here.
3. Firebase might be the 3rd choice, though the performance is arguably unclear.
4. Others (OpenSpace, RedDwarf, ElectroServer, Player.IO, Red5, Mesmotronic Multiuser Server etc.)
See this great post for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With