21
Phát trin ng dng đa nntng SmartFox Server Phm Ngc Thy Tamtay JSC

[Vietnam Mobile Day 2013] - Phát triển ứng dụng game đa nền tảng smart fox server

Embed Size (px)

Citation preview

Phát triển ứng dụng đa nền tảng– SmartFox Server

Phạm Ngọc Thủy –Tamtay JSC

Nội dung trình bày

Tại sao lại chọn SmartFox server(SFS)?

Cấu trúc, tính năng SFS

Cơ sở lập trình SFS: Các phase của SFS

SFSExtension

SFS Class

Ví dụ về các game có thể phát triển dựa trên SFS

Tại sao lại dùng SmartFox?

Tiềm năng của các game multiplayer trên mobile.

Sử dụng trong quá trình mobile hóa ứng dụng.

Phát triển các ứng dụng mobile độc lập.

SFS –Cấu trúc

Tính năng

Server core

Platform

Client

Cấu trúc Zone/Room

Cài đặt

Server

Client

SFS Phase: Connection

2 bước thực hiện kết nối:

Mở kết nối vật lý TCP tới server.

Client và server thực hiện kết nối và trao đổi các thông tin cấuhình.

Hệ thống Highly Resilient Connection (HRC):

CONNECTION_RETRY

CONNECTION_RESUME

Connection phase: Code iOS

_smartFox = [[SmartFox2XClient alloc] initSmartFoxWithDebugMode:YES delegate:self];

[_smartFox loadConfig:@"config.xml" connectOnSuccess:YES];

Config.xml:

<SmartFoxConfig>

<ip>127.0.0.1</ip>

<port>9933</port>

<blueBoxIpAddress>127.0.0.1</blueBoxIpAddress>

<blueBoxPort>8080</blueBoxPort>

<smartConnect>true</smartConnect>

<httpPort>8080</httpPort>

<httpPollSpeed>750</httpPollSpeed>

<zone>BasicExamples</zone>

</SmartFoxConfig>

Connection phase: Code iOS

SmartFox2XClient * client = [[SmartFox2XClient alloc] initSmartFoxWithDebugMode:YES delegate:self];

[client connect:@"127.0.0.1" port:9933];

SFS Phase: Login

Default_login

Custom_login

Params:

User_name

Password

Zone_name

Extra_params

Login phase: Code iOS

Custom login:

[client send:[LoginRequest requestWithUserName:[UserName] password:[Pass] zoneName:@”[ZoneName]" params:nil]];

Default login:

[client send:[LoginRequest requestWithUserName:loginName password:@"" zoneName:nilparams:nil]];

Or:

[client send:[LoginRequest request]];

SFS Phase: Join, create room

Tạo room mới:

Tĩnh

Động

JoinRoomRequest:

Id

Pass

Room_to_leave

As_spect

Join, create room: Code iOS

C1: [client send:[JoinRoomRequest requestWithId:@”[RoomName]"]];

C2: : [client send:[JoinRoomRequest requestWithId:[RoomName] pass:[RoomPassword] roomIdToLeave:[IDLastRoom] asSpect:[Spectator?]]];

Create room:

[client send:[CreateRoomRequest requestWithRoomSettings:[RoomSettings]]];

Client API

Public APIs

Custom Requests

Public APIs: Code iOS

SendRequest:

[client send:[PublicMessageRequest requestWithMessage:str]];

Response:

-(void)onPrivateMessage:(SFSEvent *)evt

{

SFSUser *sender = [evt.params objectForKey:@"sender"];

NSLog(@"PM: %@, from: %@", [evt.paramsobjectForKey:@"message"], sender.name);

}

SFSExtension

ZoneLevelExtension

RoomLevelExtension

ServerAPI

API Classes

Services

Data Classes

SFSExtension: Code iOS

SendRequest:

[client send:[ExtensionRequest requestWithExtCmd: @”[CommandName]" params:[Params]]];

Response:

-(void)onExtensionResponse:(SFSEvent *)evt

{

NSString *str = [evt.params objectForKey:@"cmd"];

SFSObject *obj = [evt.params objectForKey:@"params"];

}

Bạn đã sẵn sàng?

Ý tưởng sản phẩm.

Nhân lực.

Server.

Client:

iOS: Mac OS, iOS SDK, Xcode

Android: Android SDK, Eclipse

Ví dụ về game có thể triển khai

Turn based games.

Audition phiên bản mobile?

Hỏi & Đáp

Chân thành cảm ơn!

Thông tin diễn giả:

Phạm Ngọc Thủy –Trưởng nhóm mobile

Email: [email protected]

Công ty Cổ phần Tamtay – Số 43 LàngYên Phụ - Tây Hồ - HàNội