1 / 12

WCF デモ

WCF デモ. WCF を使ったネットワークアプリ作成. デモ内容. ゲームプロトタイプ キャラの位置を動かすだけのシンプルなもの 位置をサーバ側で管理 複数のクライアントで位置を同期. WCF とは. .NET Framework 3.0 で 追加されたウェブサービス基盤 Windows Communication Foundation http://msdn.microsoft.com/ja-jp/library/ms735119.aspx http://www.atmarkit.co.jp/fdotnet/wcf/index/index.html.

taji
Download Presentation

WCF デモ

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. WCFデモ WCFを使ったネットワークアプリ作成

  2. デモ内容 • ゲームプロトタイプ • キャラの位置を動かすだけのシンプルなもの • 位置をサーバ側で管理 • 複数のクライアントで位置を同期

  3. WCFとは • .NET Framework 3.0で追加されたウェブサービス基盤 • Windows Communication Foundation • http://msdn.microsoft.com/ja-jp/library/ms735119.aspx • http://www.atmarkit.co.jp/fdotnet/wcf/index/index.html

  4. ウェブサービスの構成要素 • エンドポイント: ABC • Address: どこで(Where) • http://ufcpp.net/Services, net.tcp://localhost/Services, etc. • Biding: どうやって(How) • HTTP/SOAP, TCP,named pipe, .NET Remoting, etc. • Contract: 何を(What) • 商取引、ゲーム、チャット、IM、SNS、etc.

  5. エンドポイント • 1つのサーバ/クライアントが複数のエンドポイントを持てます クライアント サーバ 例1: 複数のContract A: http://ufcpp.net/game B: Basic HTTP C: ゲームサーバ A A A A B B B B C C C C A: http://ufcpp.net/chat B: Basic HTTP C: チャットサーバ

  6. エンドポイント • 1つのサーバ/クライアントが複数のエンドポイントを持てます クライアント サーバ 例2: 複数のBinding A: http://ufcpp.net/game B: Basic HTTP C: ゲームサーバ A A A A B B B B C C C C A: net.pipe://localhost/game B: 名前付きパイプ C: ゲームサーバ

  7. WCFContract • WCFでは、Contract(何をするか)に注力できます • 普通の.NETクラスライブラリに属性をつけるだけ [ServiceContract] interfaceIGameCharacter { void Move(Vector movement); } [ServiceContract] interfaceIGameCharacterCallback { void SetLocation(Point location); }

  8. クラスライブラリとして利用 • Contractクラスは、単なるクラスライブラリとしても使えます デモ • ユーザからの入力に応じて丸が動く • WPFを利用

  9. WCFにおけるABC • App.config/Web.configに設定を記述 <configuration> <system.serviceModel> <client> <endpoint name="GameCharacterIis" address="http://localhost/Services/Game.svc" binding="wsDualHttpBinding" contract="WcfGameSample.IGameCharacter"> </endpoint> </client> </system.serviceModel> </configuration>

  10. デバッグ用ホストサーバ • WCFライブラリ • WCFサービスホストというデバッグ用のプログラムでホストしてくれる デモ

  11. サービスをIISでホスト • .svcファイルを記述 • ASP.NETの.aspxと同じ要領 <%@ServiceHost Language="C#" Debug="true" Service="WcfGameSample.GameCharacter"%> デモ

  12. セルフホストサーバ • ServiceHost,ChannelDispatcherクラスなどを使って自前でホスティング可能 Uri address = newUri("net.pipe://localhost/game"); NetNamedPipeBinding binding = newNetNamedPipeBinding(); Type contract = typeof(IGameCharacter); using (ServiceHostserviceHost = newServiceHost(typeof(GameCharacter))) { serviceHost.AddServiceEndpoint(contract, binding, address); Console.WriteLine("ENTERキーでサービス終了"); Console.ReadLine(); serviceHost.Close(); } デモ

More Related