0

I'm working on a project in Haxe which requires a connection to the SmartFoxServer. I installed SFS Pro (localhost:8080 opens and displays the intro page fine). I haven't modified the config files either.

Client-side, I try running SmartFoxClient.connect([my ip], 9339). After the line with connect, nothing runs and the listener SFSEvent.onConnection is never called.

import it.gotoandplay.smartfoxserver.SmartFoxClient;
import it.gotoandplay.smartfoxserver.SFSEvent;
class New {
    public static function main() {
        var sfs = new SmartFoxClient(true);
        haxe.Log.trace(sfs.properties);
        sfs.addEventListener(SFSEvent.onConnection, function(e:SFSEvent) {
            haxe.Log.trace("Listener called: " + sfs.getConnectionMode);
            if(e.params.success) {
                haxe.Log.trace("Success");
            }
            else {
                haxe.Log.trace("Success");
            }
    });
    try{
            haxe.Log.trace("Connecting Started..");
            sfs.connect("192.168.1.229", 9339);  //my ip is 192.168.1.229 on the internal network.  Tried with "127.0.0.1" and got the same result
            haxe.Log.trace("Connecting...");
    }
    catch(e:String) {
            haxe.Log.trace("Failed");
    }
    haxe.Log.trace("Connection Sent..................");
    }
}

I compile with haxe -main New -swf whatever.swf -swf-lib SmartFoxClient.swf -swf-lib SFSEvent.swf. The compilation runs fine, but the output of the traces is only `sfs.properties (which is null) and "Connecting Started.."

I tried using the similar code in Flash (that is the same exact functions) and it connected fine.

My question is if anyone has done this without porting the entire code of SFS to Haxe (which I unsuccessfully tried with as3hx), what did they do differently?

Gama11
  • 31,714
  • 9
  • 78
  • 100
user2784930
  • 15
  • 1
  • 7
  • I don't really know what I'm talking about as I never heard of SmartFoxServer, but if you are clueless maybe you have nothing to lose checking these 2 urls : http://old.haxe.org/manual/swc and http://stackoverflow.com/questions/8767423/haxenme-with-smartfox-server-integration .. Probably not going to help but who knows.. – the_yellow_logo Oct 09 '14 at 12:29
  • I've seen the links. With regards to swc, as far as I know, it's an archive with an XML and an swf. I looked at importing swc's and everyone says that importing swf using -swf-lib is the best way. I also had seen the second answer, but I'm really against porting the entire project to Haxe. I tried using Tarwin's script and as3hx, but there's still so many changes I need to make which I'm not really confident making. Thanks for the quick reply. I'll probably try asking the guy who managed to port in that question. – user2784930 Oct 09 '14 at 12:39

1 Answers1

0

In my case, the problem was that flash didn't have permission to use sockets. I changed it to a trusted file and it works fine now.

user2784930
  • 15
  • 1
  • 7