• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
閒聊Python應用在game server的開發
 

閒聊Python應用在game server的開發

on

  • 826 views

2013/06/27 在Taipei.py分享的主題

2013/06/27 在Taipei.py分享的主題

Statistics

Views

Total Views
826
Views on SlideShare
819
Embed Views
7

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 7

http://blog.fshiori.org 7

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    閒聊Python應用在game server的開發 閒聊Python應用在game server的開發 Presentation Transcript

    • 閒聊Python應用在Game Server的開發 Eric Chen
    • Agenda ● Python應用在之前的專案中 ● Django與REST應用在遊戲開發上 ● 面臨的問題與挑戰
    • Before... ● Pure Python (Socket + Epoll) ● Django + PyAMF ● Django + REST
    • Socket vs Web Service ● Socket Server ○ Real Time ■ Player location info. ■ Chat ● Web Service ○ polling
    • REST API HTTP Method Data operate Description POST Create Create a resource without id. GET Read Get a resource. PUT Update Update a resource or create a resource with id if not existed. DELETE Delete Delete a resource
    • Framework ● Django ● Django REST framework
    • Why Django REST framework? Source of photo credit :http://django-rest-framework.org/
    • Example by Puzzle & Dragon Source of photo credit :http://www.gungho.co.jp/
    • Game flow 選擇關卡 進入戰鬥 卡片編輯 Source of photo credit :http://www.padpadblog.com/2012/11/blog-post_6024.html & http://zh.pad.wikia.com/wiki/Puzzle_%26_Dragons_%E7%BB%B4% E5%9F%BA 隊伍編輯
    • API ● /api/login/ ● /api/players/me/ ● /api/stages/ ● /api/cards/ ● /api/cards/groups/ ● etc...
    • Login models.py class Player(models.Model): access_token = models.CharField(max_length=255) level = models. exp = models. money = models ... serializer.py class LoginSerializer(serializers.Serializer): access_token = serializers.CharField() api.py class LoginView(APIView): def post(self, request): serializer = SnippetSerializer(data=request.DATA) if not serializer.is_valid(): return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) player, created = Player.objects.get_or_create(access_token=access_token) result = {} request.session['player_id'] = player.id return Response(result)
    • Problem ● 資料庫存取次數 ● 資料庫延遲 ● Application Server 效能問題
    • ● 減少Server端計算 ● 修改企劃 ● 資料庫分割 ● 快取 ● NOSQL ● Queue
    • Q&A