facebook flash api and social game development

44
Facebook Flash API and Social Game Development http://fb.me/tempofeng

Upload: yenwen-feng

Post on 22-Dec-2014

3.911 views

Category:

Technology


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Facebook flash api and social game development

Facebook Flash APIand Social Game Development

http://fb.me/tempofeng

Page 2: Facebook flash api and social game development

Agenda

• Gamelet–Our Experiences

• Tips & Tricks– Flash– Social– Facebook / Flash

• Q & A

Page 3: Facebook flash api and social game development

Gamelet: Our Experiences

Page 4: Facebook flash api and social game development

Gamelet

Page 5: Facebook flash api and social game development

Web Traffics

Page 6: Facebook flash api and social game development

Gamelet

• Published 17 Games– 15 Real-Time Synchronized Games– 2 Social Games

• 11 Employees– 6 Engineers– 3 Arts

Page 7: Facebook flash api and social game development

Gamelet

• Bandwidth– 60M/Month

• Online Users– 8000 users (max)

• Aggregated MAU– 400K (down from 800k)

Page 8: Facebook flash api and social game development

Servers

• Web Servers– apache -> tomcat– 2xDell PE R610 (1 Master-N Slave)

• 2xI5520, 6GB, SAS HDs

• Static Files Servers– 1xPC

• Real-time Socket Servers– Java/Mina/ActiveMQ– 3xDell PE R610

• 1xI5520, 6GB, SAS HDs

Page 9: Facebook flash api and social game development

Servers

• DB Servers–MySQL• 2xDell PE R710 (1Master, 1Standby)

– 2xI5530, 32GB, SAS HDs

– Cassandra• 2xDell PE R710

– 2xI5530, 32GB, SAS HDs

Page 10: Facebook flash api and social game development

Tip & Tricks - Flash

• Development Environment• Art/Developers Workflow• Performance• Fighting Cheaters• Loader• crossdomain.xml

Page 11: Facebook flash api and social game development

Development Environment

• Developers– Flash(Flex) Builder• Flex Components• Slow

– Ram/CPU/SSD– Open Too Many Projects

• Arts– Illustrator/Photoshop/Flash

Page 12: Facebook flash api and social game development

Arts/Developers Workflow

.fla .swf, swc game.swf

Designers Programmers

.as

Page 13: Facebook flash api and social game development

Versioning Graphics Assets

• Confusing!– SVN–Development Mode• car.fla, airplane.fla

– Production Mode• car.fla, airplane.fla -> vehicle_v00.swf

Page 14: Facebook flash api and social game development

Performance

• Monitoring Framerate• Don’t– Alpha, 變形工具– Large Bitmap– Parent/child Movieclip

• Using– Sprite instead of Movieclip

Page 15: Facebook flash api and social game development

Performance

• Slow Movieclip– cacheAsBitmap• Rotate, Scale, …

– AnimationSlicer• http://blog.vandenoostende.com/2008/

animationslicer/

• Profiler–Memory Leak

Page 16: Facebook flash api and social game development

Fighting Cheaters

• Manipulating Memory• Intercepting Packets• Accelerators• Double Login• Manipulating Code• Building a Bot• Fake Accounts

Page 17: Facebook flash api and social game development

Manipulating Memory

Page 18: Facebook flash api and social game development

Manipulating Memory

• Cheat Engine– http://www.cheatengine.org/

• Encode Critical Data–Heap Data– Scores, Weapon, …

Page 19: Facebook flash api and social game development

Manipulating Memory• class SecureInteger• {• int number;• int checksum;• public void setNumber(int number)• {• this.number = number;• this.checksum = md5(number);• }• public int getNumber()• {• if(verifyMd5(number, checksum))• return number;• else• throw new SecurityException();• }• }

Page 20: Facebook flash api and social game development

Intercepting Packets

• Add Signature• Encode– SSH– proprietary PKI solution

Page 21: Facebook flash api and social game development

Accelerators

• 變速精靈– http://tw.vrbrothers.com/speeder/

Page 22: Facebook flash api and social game development

Accelerators

• Use Server Time Everywhere• Detecting– Calculate the difference between

client time & server time–Network latency will be hard to

predict

Page 23: Facebook flash api and social game development

Double Login

• Logout Previous Logined User– Flash LocalConnect– Server Notification

Page 24: Facebook flash api and social game development

Manipulating Code

• Obfuscator• Dynamically Download Encoded

SWF– Loader.loadBytes(bytes)

Page 25: Facebook flash api and social game development

Building a Bot

• Monitoring–Monitoring All Service Interfaces– AOP, Annotation

• Limiting resource update– Limit by Time Period– Limit by User Roles, Levels• Guests, Unregistered Users

Page 26: Facebook flash api and social game development

Fake Accounts

• Limit Help from Friends

Page 27: Facebook flash api and social game development

Loader

• Loading Static Files– Always Retry!

Page 28: Facebook flash api and social game development

crossdomain.xml

• crossdomain.xml– Access Remote Files

• Security.allowDomain()– SWFs from Other Domain to Access

Me• loader.loaderContext = new

LoaderContext(true, ApplicationDomain.currentDomain)

– Access Remote Image Files without crossdomain.xml

Page 29: Facebook flash api and social game development

Tips & Tricks – Social Games

• Game Design• Viral Channels• Data Storage

Page 30: Facebook flash api and social game development

Game Design

• Beautiful!• Gifting is the New Poke• Don’t Punish Users• Represent Relations between

Friends

Page 31: Facebook flash api and social game development

Viral Channels

monfriends

Page 32: Facebook flash api and social game development

Data Storage

• Read:Write = 1:1• MySQL– Transactional–Data Growing Slowly

• Cassandra– Key/Value–Data Growing Fast

Page 33: Facebook flash api and social game development

Tips & Tricks – Facebook / Flash

• Facebook API / Graph API• Chinese Input• Invite/Request without Page

Reloaded

Page 34: Facebook flash api and social game development

Facebook API & Graph API

• No Plan of Updating• Recommend– Calling Javascript API from Flash

ExternalInterface

• if (!ExternalInterface.available)• {• return;• }

• ExternalInterface.call("lumixInviteFriends", invite, title, type, content, url, label, condensed, toUid(username));

Page 35: Facebook flash api and social game development

wmode = ‘opaque’

Page 36: Facebook flash api and social game development

wmode = ‘window’

Page 37: Facebook flash api and social game development

Chinese Input

• Flash 9/10–Only wmode = ‘window’ Can Input

Chinese–Will Hide javascript Windows

• Flash 10.1–wmode = ‘opaque’ can input

Chinese in IE/Firefox

Page 38: Facebook flash api and social game development

Flash 9,10 + wmode = ‘window’

Move or Hide the Flash

Page 39: Facebook flash api and social game development

Invite/Request without Page Reloaded

Page 40: Facebook flash api and social game development

Step 1: Dynamically Add an <iframe>

• <iframe id='inviteFriendsIframe' name='inviteFriendsIframe' src='inviteFriendsIframe.do' scrolling='no' frameborder='0' width='760' height='800'></iframe>

Page 41: Facebook flash api and social game development

Step 2: <fb:request-form> in <iframe>

• <fb:serverFbml>• <fb:request-form action="closeFbmlIframe.do" invite="" type="" …>• …• </fb:request-form>• </fb:serverFbml>

Page 42: Facebook flash api and social game development

Step 3: Close the <iframe> by Javascript

• <script type="text/javascript">• $(document).ready(function()• {• window.parent.onFbmlIframeClosed();• });• </script>

Page 43: Facebook flash api and social game development

Thanks

Page 44: Facebook flash api and social game development

http://apps.facebook.com/pizzaworld_tw/Pizza 世界