Package | jp.co.fujitsu.reffi.client.flex.model.messaging |
Class | public class ConsumerCore |
Inheritance | ConsumerCore ![]() ![]() |
[概 要]
発行されているサーバメッセージデスティネーションをクライアントで購読する為の機能モデルクラスです.[詳 細]
サーバ側(LCDS及びBlazeDS)のmessaging-config.xmlで定義されているdestinationを購読開始、停止します。
この機能モデルを拡張したモデルを作成する場合、onSuccessメソッドとonFailureメソッドをオーバーライド
することで、メッセージ受信成功処理、失敗処理を実装することが出来ます。
[備 考]
public class SubscribeStartAction extends BaseAction { // ① subscribeを行うConsumerCore機能モデルを登録します override protected function reserveModels(models:Array):void { models.push(Class(ConsumerCore)); } // ② ConsumerCoreインスタンスの設定を行います。このケースではpublishDemoデスティネーションを購読します override public function nextModel(index:int, prev:ModelProcessEvent, next:BaseModel):Boolean { switch (index) { case 0: ConsumerCore(next).destination = "publishDemo"; break; } return true; } // ③ メッセージ購読成功時の処理を実装します // ConsumerCoreは継続的にSUCCESSイベントを返却する為、subscribe停止するまで // このメソッドへのコールバックが継続します // ConsumerCoreManagerを使用することで任意のタイミングでsubscribe停止可能です override public function successForward(index:int, model:BaseModel, resultEvent:Event):void { var list:ArrayCollection = getObjectById("serverPushArrayCollection") as ArrayCollection; list.list = MessageEvent(resultEvent).message.body as ArrayCollection; if(model.successCount == 3) { ConsumerCoreManager.getInstance().unsubscribe("publishDemo"); } } // ④ 登録モデルが完全に完了した時に呼ばれるメソッドを実装します // 継続的に値を返却するモデルの完了タイミングをハンドルします override public function complete():void { trace("subscribe is done."); } }
public class SubscribeStopAction extends BaseAction { // ① subscribe停止を行うConsumerCore機能モデルを登録します override protected function reserveModels(models:Array):void { models.push(Class(ConsumerCore)); } // ② subscribeモードをfalseに設定したConsumerCoreが実行されることでsubscribe停止します // 同一destinationをsubscribeしているConsumerCoreが複数存在するケースで、任意のConsumerCore // だけsubscribeを停止する場合、開始時に設定しておいたidentifierを指定することが出来ます // identifierが指定されなかった場合は同一destinationをsubscribe中の全ConsumerCoreがsubscribe停止します override public function nextModel(index:int, prev:ModelProcessEvent, next:BaseModel):Boolean { switch (index) { case 0: ConsumerCore(next).destination = "publishDemo"; ConsumerCore(next).subscribe = false; ConsumerCore(next).identifier = "client1"; break; } return true; } }
Copyright (c) 2008-2009 FUJITSU Japan All rights reserved.
関連項目
Property | Defined by | ||
---|---|---|---|
channelSet : ChannelSet [概 要] 任意設定可能な通信チャンネルセットです. | ConsumerCore | ||
![]() | controller : BaseController
[概 要] このモデルを起動したコントローラインスタンスです. | BaseModel | |
destination : String [概 要] メッセージ受信を行う対象のdestinationです. | ConsumerCore | ||
![]() | executeIndex : int [概 要] 実行インデックス設定. | BaseModel | |
identifier : String [概 要] 購読中のConsumerCoreを特定する為の識別子です. | ConsumerCore | ||
![]() | parameterMapping : ParameterMapping
[概 要] MVC各レイヤを伝播するパラメータオブジェクトです. | BaseModel | |
![]() | skip : Boolean [概 要] このモデルを実行するか、コントローラが判断する為のフラグです. | BaseModel | |
subscribe : Boolean [概 要] 購読開始/購読停止を示すフラグです. | ConsumerCore | ||
![]() | successCount : int [概 要] モデルインスタンス生存中に、何回モデル処理が成功したかを保持します. | BaseModel |
Method | Defined by | ||
---|---|---|---|
![]() |
dispatchModelFailure(event:ModelProcessEvent):void
[概 要] モデル処理失敗イベントを発行するメソッドです. | BaseModel | |
![]() |
dispatchModelFinished(event:ModelProcessEvent):void
[概 要] モデル処理完了イベントを発行するメソッドです. | BaseModel | |
![]() |
dispatchModelSuccess(event:ModelProcessEvent):void
[概 要] モデル処理成功イベントを発行するメソッドです. | BaseModel | |
faultHandler(event:MessageFaultEvent):void
[概 要] subscribe受信失敗時にコールバックされるメソッドです. | ConsumerCore | ||
![]() |
incrementSuccessCount():int
[概 要] ModelProcessEvent.SUCCESS発行回数を1増加させます. | BaseModel | |
resultHandler(event:MessageEvent):void
[概 要] subscribe受信時にコールバックされるメソッドです. | ConsumerCore | ||
![]() |
run():void
[概 要] コントローラにコールされるモデルの主幹メソッドです. | BaseModel |
Method | Defined by | ||
---|---|---|---|
![]() |
finallyProc():void
[概 要] run()が終了したタイミングでテンプレートコールされるメソッドです. | BaseModel | |
mainProc():void
[概 要] サーバに対して購読の開始、停止処理を行います. | ConsumerCore | ||
onFailure(event:MessageFaultEvent):void
[概 要] subscribe受信失敗オーバーライド用メソッドです. | ConsumerCore | ||
onSuccess(event:MessageEvent):void
[概 要] subscribe結果受信オーバーライド用メソッドです. | ConsumerCore | ||
![]() |
postProc():void
[概 要] 後処理テンプレートメソッドです. | BaseModel | |
![]() |
preProc():Boolean
[概 要] 前処理テンプレートメソッドです. | BaseModel | |
![]() |
trap(e:Error):Error
[概 要] run()内で発生した全例外をハンドリングするメソッドです. | BaseModel |
channelSet | property |
channelSet:ChannelSet
[read-write]
[概 要]
任意設定可能な通信チャンネルセットです.[詳 細]
[備 考]
実装 public function get channelSet():ChannelSet
public function set channelSet(value:ChannelSet):void
destination | property |
destination:String
[read-write]
[概 要]
メッセージ受信を行う対象のdestinationです.[詳 細]
LCDS及びBlazeDSのmessaging-config.xmlで定義されているdestinationを設定します。[備 考]
実装 public function get destination():String
public function set destination(value:String):void
identifier | property |
identifier:String
[read-write]
[概 要]
購読中のConsumerCoreを特定する為の識別子です.[詳 細]
同一destinationを購読するConsumerCoreが複数有る場合、 任意のConsumerCoreを特定する為に使用するプロパティです。[備 考]
実装 public function get identifier():String
public function set identifier(value:String):void
開始
override public function nextModel(index:int, prev:ModelProcessEvent, next:BaseModel):Boolean { switch (index) { case 0: ConsumerCore(next).destination = "chatRoom"; ConsumerCore(next).identifier = "yamada"; break; } return true; }
override public function nextModel(index:int, prev:ModelProcessEvent, next:BaseModel):Boolean { switch (index) { case 0: ConsumerCore(next).destination = "chatRoom"; ConsumerCore(next).subscribe = false; ConsumerCore(next).identifier = "yamada"; break; } return true; }
subscribe | property |
subscribe:Boolean
[read-write]
[概 要]
購読開始/購読停止を示すフラグです.[詳 細]
true:購読開始[備 考]
The default value is true
.
public function get subscribe():Boolean
public function set subscribe(value:Boolean):void
faultHandler | () | method |
public function faultHandler(event:MessageFaultEvent):void
[概 要]
subscribe受信失敗時にコールバックされるメソッドです.[詳 細]
ConsumerCoreManagerに管理されているConsumerのMessageFaultEvent.FAULTイベントハンドラ からコールバックされます。[備 考]
このメソッドはオーバーライド出来ません。event:MessageFaultEvent — メッセージ受信失敗イベント
|
mainProc | () | method |
protected override function mainProc():void
[概 要]
サーバに対して購読の開始、停止処理を行います.[詳 細]
subscribe管理オブジェクト(ConsumerCoreManager)を取得し、購読の開始、中止を委譲します。
購読中止(subscribeプロパティ == false)時、ConsumerCoreManager#unsubscribeメソッド処理が
例外をスローしなかった場合は、その時点でModel処理成功イベントを発火します。
[備 考]
購読中止時のModel処理成功イベント内結果オブジェクトはnullです。 利用することは出来ません。onFailure | () | method |
protected function onFailure(event:MessageFaultEvent):void
[概 要]
subscribe受信失敗オーバーライド用メソッドです.[詳 細]
[備 考]
パラメータevent:MessageFaultEvent — メッセージ受信失敗イベント
|
onSuccess | () | method |
protected function onSuccess(event:MessageEvent):void
[概 要]
subscribe結果受信オーバーライド用メソッドです.[詳 細]
[備 考]
パラメータevent:MessageEvent — メッセージ受信イベント
|
resultHandler | () | method |
public final function resultHandler(event:MessageEvent):void
[概 要]
subscribe受信時にコールバックされるメソッドです.[詳 細]
ConsumerCoreManagerに管理されているConsumerのMessageEvent.MESSAGEイベントハンドラ からコールバックされます。[備 考]
このメソッドはオーバーライド出来ません。event:MessageEvent — メッセージ受信イベント
|