Upload
aiti-education
View
919
Download
3
Embed Size (px)
Citation preview
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 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];
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]]];
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: 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
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