Upload
buff-nguyen
View
2.477
Download
2
Tags:
Embed Size (px)
DESCRIPTION
Presentation in OGDC 2012 organized by VNG Corp.
Citation preview
A Practical Architecture Design For MMO Casual Game
Ngô Thái An
Content
• Happy Me• Architecture Overview• Architecture Detail
Object Management SystemServer-Client Data SynchronizationNetwork Message Dispatching System
Happy Me
Happy Me
• MMO casual game• Room-based active server• Web-based Unity3D client• Run on social platform
In-game screenshots
About technical team
• 3 system and framework developers• 4 game developers• 12 months of development
Architecture Overview
MMO game physical architecture
Database
Game Servers
Client
Internet
Game data, logic, presentation
Server Side Client Side
Game Logic
PresentationOf A Player
PlayerData
PlayerData
PlayerData
PresentationOf A Room
MODEL
CONTRO-LLERVIEW
Which design to adapt ?
A minimalist game system
Object Management
System
Network Message
Dispatching System
Auto Synchronization Framework
REQUIRE
REQUIRE
MAKE OUR LIFE EASIER
Initial requirements
• Object management system MVC design pattern Dynamic data
• Auto synchronization framework Truly automatic («Set» and forget style) Synchronize the delta difference only
• Network message dispatching system Custom structure message Easy to register messages and invoke
handlers
Object Management System(MVC Design)
Overview diagram
Model
View
Controller
(gameplay logic)
Database
Network Message
s
View
Controller
(graphic logic)
Server Side
Client Side
Unity3D
3D Models
Database
Model
MVC objects mapping
Model
View
Controller
Game Objects
Object Views
Game Logic
Modules
Rooms
Detail diagram
Game Objects
Object Views
Game Logic
No-SQL(Storage)
Network Message
s
Object Views
Graphic Logic
Server Side
Client Side
SQL(Ranking,
Log)
Database
Game Objects
Modules Modules
Rooms Rooms
General purpose base object
Object
Rooms
ObjectViews
ModulesGame
Objects
The “Object” requirements
• A container of properties• Serialize to and deserialize from JSON• Hierarchy relationship (parent-child)
Object dynamic properties
Object
Guid
Property 1Property 2
Property Meta Data
• Tags• Persistent• Client transfer
• Type• Long
• Name• “property 2”
• Version• 568
Define the properties
The object tree
Object
Unit
GameObject
DataObject
Player
DecoItem
Pet
UseItem
ClothItem
Item
Quest
Job
PlayerView
DecoView PetView
ObjectView
Module
MainGame
Authen
HomeDeco
SyncData
Room
Lobby Public Personal
Object Manager
ResultPros• MVC design pattern practice• Fully customizable property system• Manage game world into one single
system
Cons• Challenge to manage huge number
of objects
Auto Synchronization Framework(Server <-> Client)
Synchronization concept
ServerRoomPlayer.Position = (10,
20)
Player.OnUpdatePosition(10, 20){ model.MoveTo(10, 20);}
Client
Duties of a room
SynchronizationScheduler
OtherScheduler
s
MessageProcessor
ROOM
• Process messages from clients
• Send or broadcast messages to clients
• Synchronize data changes between server and clients
• Update status• Other duties…
Thread pool workers
Personal Room
Coffee Room
Downtown Room
Sync
Other
Sync
Thread Pool
Other
Sync
Other
Sync
Sync
Other
ROOMS
TASK QUEUE
S
WORKERS
Thread
Schedulers 1 second
SYNCHRONIZATIONSCHEDULER
OTHERS SCHEDULER
1/10 second
Other Task
Sync Task
Sync Task
Other Task
Sync Task
Other Task
TASK QUEUE
WORKER
Object change-set
ObjectPosition
Energy
Gold
Change Set
SYNCHRONIZATIONSCHEDULER
SetProperty(Position, (1, 2))
Sync Task
ResultPros• Automatic synchronization property
changes• Optimal data transfer• Best use for active server game
Cons• Overhead to determine what has
changed since last sync.
Network Message Dispatching System
Custom message structureLogin- Usernam
e- Password
Synchronize- Type- Propertie
s
Buy Item- ItemType- Quantity
Chat- Message
RequestFriend- FriendGuid
Serializer(Thrift, Protobuf, Json,
XML)
Network package
Encryption
Message factory
Server
Send
Client
Receive
Serialize
Deserialize
Login- Username- Password
Login- Username- Password
OnAuthen
OnMove
OnRun
LoginAuthenMoveRun
Message Handlers
OnLogin
ResultPros• Meaningful message by define
custom structure• Familiar usage as common GUI
system (MFC, WinForm)• Share message definition between
server and client• Easy to apply encryptionCons• Unknown
Conclusion
• Seamless MVC framework across server and client
• Address the most common difficulty in design active server : the synchronization
• Base framework environment for adapting any gameplay
Q&A