Original post here .
In particular, you can connect to the smartfox server and receive connection notifications:
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 log in and log in when logging in successfully:
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 a ready-made framework for multiplayer games. Start from scratch or create your own custom logic on top of several demo applications included in the source code with free server SDKs. This allows you to achieve great results quickly and easily.
Code snippet for installation connection:
using UnityEngine; public class RandomMatchmaker : MonoBehaviour { void Start() { PhotonNetwork.ConnectUsingSettings("0.1"); } void OnGUI(){ GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString()); } }
Fragment code for room / lobby:
public override void OnJoinedLobby() { PhotonNetwork.JoinRandomRoom(); }
Code snippet for registering settings:
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 may be the third choice, although performance may be obscure.
- As an example, at roll20.net , you can find a Firbase -based MMO game.
- Among others, FireSharp can be a very useful open source project for quick launch.
4. Others (OpenSpace, RedDwarf, ElectroServer, Player.IO, Red5, Mesmotronic Multi-User Server, etc.)
See excellent post for more details.