using UnityEngine;
using System.Collections;
using Sfs2X;
using Sfs2X.Core;
using Sfs2X.Requests;
using Sfs2X.Entities;
public class NetworkingClient : MonoBehaviour {
private string host = “localhost”; //The ip the client tries to connect to
private int port = 9933; //The port the client tries to connect to the server on
public SmartFox _client;
// Use this for initialization
void Start () {
_client = new SmartFox ();
_client.ThreadSafeMode = true;
_client.AddEventListener(SFSEvent.CONNECTION, OnConnection;
Connect ();
}
// Update is called once per frame
void FixedUpdate () {
_client.ProcessEvents();
}
public void Connect() {
_client.Connect (host, port:);
}
// Use this for initialization
void Start () {
_client = new SmartFox ();
_client.ThreadSafeMode = true;
_client.AddEventListener(SFSEvent.CONNECTION, OnConnection); // <--- This bracket was missing
Connect ();
}
using UnityEngine;
using System.Collections;
using Sfs2X;
using Sfs2X.Core;
using Sfs2X.Requests;
using Sfs2X.Entities;
public class NetworkingClient : MonoBehaviour {
private string host = "localhost"; //The ip the client tries to connect to
private int port = 9933; //The port the client tries to connect to the server on
public SmartFox _client;
// Use this for initialization
void Start () {
_client = new SmartFox ();
_client.ThreadSafeMode = true;
_client.AddEventListener(SFSEvent.CONNECTION, OnConnection);
Connect ();
}
// Update is called once per frame
void FixedUpdate () {
_client.ProcessEvents();
}
public void Connect() {
_client.Connect (host, port:);
}
void OnConnection(BaseEvent _event) {
if((bool)_event.Params["success"]) {
//Successful
Debug.Log ("Successfully connected to server");
} else {
//Failed
Debug.Log ("Failed connecting to server");
}
}
}
You were missing a curly bracket at the end of the script.
In order to identify these problems quickly you should try to keep your code well formatted.