Hi,
I am trying to connect to smart-fox from my Unity.
but except to 'Connecting' i didnt see anything.
obviously i am using SFS dll, my sfs is running and able to access my localhost/sfs-admin panel. also no erro/info from unity.
using UnityEngine;
using System.Collections;
using Sfs2X;
using Sfs2X.Core;
using Sfs2X.Entities;
using Sfs2X.Requests;
using Sfs2X.Logging;
public class SmartFoxConnector : MonoBehaviour {
// Use this for initialization
private SmartFox _smartFox;
public string serverIP = "127.0.0.1";
public int serverPort = 9339;
void Start () {
}
// Update is called once per frame
void Update () {
}
void Awake()
{
Application.runInBackground = true;
_smartFox = new SmartFox(true);
_smartFox.AddEventListener(SFSEvent.CONNECTION, onConnectToSmartFoxServer);
_smartFox.AddEventListener(SFSEvent.CONNECTION_LOST, onConnectionLost);
_smartFox.Connect(serverIP, serverPort);
}
public void onConnectionLost(BaseEvent evt)
{
Debug.Log("Connecting");
}
public void onConnectToSmartFoxServer(BaseEvent evt)
{
bool success = (bool)evt.Params["success"];
string error = (string)evt.Params["errorMessage"];
Debug.Log("On Connection callback got: " + success + " (error : <" + error + ">)");
}
}
Unable to connect to SFS from C# (noob quest).
-
- Posts: 6
- Joined: 11 Aug 2011, 03:22
- Location: Gurgaon
- Contact:
You need to enable processing the events by doing :
Code: Select all
void FixedUpdate () {
smartFox.ProcessEvents ();
}
-
- Posts: 6
- Joined: 11 Aug 2011, 03:22
- Location: Gurgaon
- Contact:
appels wrote:You need to enable processing the events by doing :Code: Select all
void FixedUpdate () {
smartFox.ProcessEvents ();
}
Thanks for the help, it works fine, but now new problem -
Connection error: No connection could be made because the target machine actively refused it.
i dont have any idea about the error, however i am well versed with ActionScript3 + java + SmartFox.
the same code in as3 is working fine, but my machine is refusing for only Unity's Connection.
-
- Posts: 6
- Joined: 11 Aug 2011, 03:22
- Location: Gurgaon
- Contact:
manoj_sahu wrote:appels wrote:You need to enable processing the events by doing :Code: Select all
void FixedUpdate () {
smartFox.ProcessEvents ();
}
Thanks for the help, it works fine, but now new problem -
Connection error: No connection could be made because the target machine actively refused it.
i dont have any idea about the error, however i am well versed with ActionScript3 + java + SmartFox.
the same code in as3 is working fine, but my machine is refusing for only Unity's Connection.
problem solved, i was using wrong port (9339 instead of 9933).
thanks for the help @appels once again.
Who is online
Users browsing this forum: No registered users and 71 guests