2014-10-09 17 views
0

我正在開發Haxe中需要連接到SmartFoxServer的項目。我安裝了SFS Pro(本地主機:8080打開並正常顯示介紹頁面)。我還沒有修改配置文件。Haxe未連接到SmartFoxServer PRO 1.6.6

客戶端,我嘗試運行SmartFoxClient.connect([my ip], 9339)。在connect之後,沒有任何運行,並且從不調用收聽者SFSEvent.onConnection

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.................."); 
    } 
} 

我編譯haxe -main New -swf whatever.swf -swf-lib SmartFoxClient.swf -swf-lib SFSEvent.swf。編譯運行良好,但跟蹤的輸出只是`sfs.properties(這是null)和「Connecting Started ..」

我嘗試使用Flash中的類似代碼(即相同的確切功能)和它連接好。

我的問題是,如果任何人沒有將整個SFS代碼移植到Haxe(我沒有成功嘗試使用as3hx),他們做了什麼不同?

+0

我真的不知道我在說什麼,因爲我從來沒有聽說過SmartFoxServer,但如果你不知道,也許你沒有什麼可以去檢查這兩個URL:http://old.haxe.org/manual/ SWC和http://stackoverflow.com/questions/8767423/haxenme-with-smartfox-server-integration ..可能不會幫助,但誰知道.. – 2014-10-09 12:29:17

+0

我見過的鏈接。關於swc,據我所知,它是一個帶有XML和swf的存檔。我研究了導入swc,並且每個人都說使用-swf-lib導入swf是最好的方法。我也看到了第二個答案,但我真的反對將整個項目移植到Haxe。我嘗試使用Tarwin的腳本和as3hx,但仍然有很多我需要做的改變,而我並沒有真正的自信。感謝您的快速回復。我可能會試着問那個設法在那個問題上移植的人。 – user2784930 2014-10-09 12:39:09

回答

0

在我的情況下,問題是閃存沒有使用套接字的權限。我將它更改爲可信文件,現在它工作正常。