Pyramid + socket.io 人狼を作ってみた
Upcoming SlideShare
Loading in...5
×
 

Pyramid + socket.io 人狼を作ってみた

on

  • 234 views

Pyramid + socket.io で人狼を作りました。PyConJP 2014 の LT 発表資料です。 ...

Pyramid + socket.io で人狼を作りました。PyConJP 2014 の LT 発表資料です。

- 人狼アプリ: http://ec2-54-64-134-137.ap-northeast-1.compute.amazonaws.com/
- ソースコード: https://github.com/ledmonster/werewolf

Statistics

Views

Total Views
234
Views on SlideShare
191
Embed Views
43

Actions

Likes
4
Downloads
1
Comments
0

1 Embed 43

https://twitter.com 43

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

Pyramid + socket.io 人狼を作ってみた Pyramid + socket.io 人狼を作ってみた Presentation Transcript

  • Pyramid + socket.io 人狼を作ってみた PyCon JP 2014 林 淳哉
  • Who am I ? • 林 淳哉(35歳) • 1児のパパ • Python 歴10年くらい? • Pylons, Pyramid
  • みんなの人狼 村に参加して、 チャットで人狼。 ! Web API + JavaScript http://bit.ly/YAb5f7
  • https://github.com/ledmonster/werewolf
  • DDDを 意識してみた
  • UI App Domain Infra Backend /api /socket.io Pyrmid View Namespace Game Domain Repository Flywheel User Domain Message Handler Frontend Repository Web Page Router Handlebars Bacon.app View Model jQuery Bacon.js
  • UI App Domain Infra Backend /api /socket.io Pyrmid View Namespace Game Domain Repository Flywheel User Domain Message Handler Frontend Repository Web Page Router Handlebars Bacon.app View Model jQuery Bacon.js Pyramid socket.io Bacon.js Flywheel handlebars
  • Backend
  • Backend • AWS • Python • Pyramid • gevent-socketio • google-api-python-client • DynamoDB
  • ルーティング
  • チャット gevent-socketio へ委譲
  • ChatNamespace • ディスパッチ • MessageHandler へ処理を委譲 • Client へメッセージを送信
  • Frontend
  • Frontend • 構成管理 • npm • gulp • bower • bacon.js • handlebars • socket.io-client
  • 送受信
  • bacon.app bacon.js ベースの社内FWを利用 • ルーティング • View の描画 • Event 処理 • DOM: bacon.js • socket.io https://github.com/xica/bacon.app
  • DDD
  • UI App Domain Infra Backend /api /socket.io Pyrmid View Namespace Game Domain Repository Flywheel User Domain Message Handler Frontend Repository Web Page Router Handlebars Bacon.app View Model jQuery Bacon.js
  • コンテキストマップ ! 1. ユーザ、認証 2. 人狼 3. チャット ※ 妄想込みなので注意
  • ドメインモデル • Entity の識別子に UUID を利用 • Value Object には Enum 型を活用 • namedtuple も使えるかも?
  • リポジトリ • ドメインモデルからのアクセスは・・・? • NG派: アプリ層のサービスで処理 • OK派: リポジトリの I/F は知っててOK • Pyramid の Root Factory を使って、 context として各ビューに引き渡した。 http://www.infoq.com/jp/news/2008/02/ddd-di-aop
  • ドメインイベント • DDD本には載ってない重要オブジェクト • ドメイン層のイベントを他のレイヤーやコンテキ ストに通知する仕組み • 例: ゲーム → EventBus → チャット • Pyramid Event が活用できる? • EventModel として永続化した ※ 人狼では EventBus の実装が間に合わず
  • コアドメイン • コンテキストマップの中で、 事業的に最も集中すべきドメイン • もっと早く知りたかった・・ この1ヶ月、コアドメイン(人狼) 以外の実装しかやってなかった・・・
  • まとめ • Pyramid で DRY な開発ができる • SPA に bacon.js はオススメ • Python でも DDD は役に立つ • (Flywheel はまだちょっと微妙) • iPhone アプリ版を作りたい
  • https://github.com/ledmonster/werewolf