官术网_书友最值得收藏!

Locating the Flash Client API

API is Application Programming Interface that allows other software to interact with it. Flash Client API for SmartFoxServer is the interface that allows Flash to connect to the SmartFoxServer and interact with it.

The following code snippet shows how Flash uses the client API to interact with SmartFoxServer.

Create an instance of client API object:

var client = new SmartFoxClient();

Connect the client to the SmartFoxServer with specific IP address and port number:

client.connect("127.0.0.1",9339);

The connection between the Flash client and the SmartFoxServer is established now. Next, we log in the user to the zone simpleChat with the username John.

client.login("simpleChat","John","");

Send public messages to all users in the same room:

client.sendPublicMessage('Hello SmartFoxServer');

The Flash Client API is located in SmartFoxServer installation directory | Flash API. There are four directories inside it. They are ActionScript 2.0, ActionScript 3.0, RedBoxClient_AS2, and RedBoxClient_AS3. RedBoxClient is the client API for connecting the media streaming Red5 component that we will not use for the virtual world development now. What we will focus on is the ActionScript 3.0 client that is for SmartFoxServer. We will have a step-by-step example in the next chapter to set up our first Flash application to connect to SmartFoxServer.

主站蜘蛛池模板: 宁安市| 洞头县| 蒙自县| 建德市| 忻城县| 长沙县| 阳信县| 宿州市| 兴和县| 元阳县| 黑龙江省| 杭锦后旗| 元阳县| 张家港市| 长顺县| 新田县| 扎兰屯市| 沅江市| 建昌县| 崇左市| 吉木乃县| 河源市| 衡水市| 茌平县| 贵阳市| 凤翔县| 迁西县| 新宁县| 鄂温| 读书| 双鸭山市| 资兴市| 鹤壁市| 神木县| 阳原县| 大连市| 明光市| 德庆县| 施秉县| 贵州省| 赞皇县|