在unity中使用smartfoxserver

來源:互聯網
上載者:User

 這裡不會提到怎麼去配置smartfoxserver. 以下的內容假設smartfoxsever已經成功啟動了。

至於怎麼配置smartfoxserver,包括怎麼實現smartfoxserver的擴充,請參看http://www.smartfoxserver.com/docs/index.htm。

 

關於用戶端怎麼樣和smartfoxserver串連,通訊。smartfoxserver的官方網站也提供了相應的資料,請參看:

http://www.smartfoxserver.com/labs/API/

 

這個頁面提供了所有smartfoxserver用戶端支援的語言和平台。

iPhone/iPod API

.Net/Mono/Unity 3D

Silverlight API

Java EE/SE/Android

Director/Shockwave

AJax

 

你可以在

http://download.csdn.net/detail/huangxiansheng1980/3596419下載到你對應的庫。

 

在unity中我們可以選用c#和java,但是因為unity支援c#而不直接支援java,因此我們選用c#.

從下面的網址下載對應的庫,裡面也包括詳細的例子,包括怎麼串連到smartfoxserver.

 

裡面會有一個dll檔案,位置在./API/binaries/,所有跟smartfoxserver直接互動的東西,全部在這個dll中。將這個dll檔案(SmartFoxClient.dll)拷貝到你的unity的工程的assets的檔案下的plugins檔案下面,如果沒有這個檔案夾,手動建立一個。

 

然後在要使用它的地方,加上:

using SmartFoxClientAPI;

就可以使用其中的類了。最簡單的讓client串連smartfoxserver:

 private string ip = "127.0.0.1";
 private int port = 9339;
 private string statusMessage = "";

 //----------------------------------------------------------
 // Called when program starts
 //----------------------------------------------------------
 void Start()
 {
  SmartFoxClient smartFox = new SmartFoxClient();
  SFSEvent.onConnection += HandleConnection;
  smartFox.Connect(ip, port);
 }

 

其他更加詳細的東西請參看下載包裡的例子和smartfoxserver的官方網站:www.smartfoxserver.com

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.