package Ġorg . t esser akt . disk ord in . gateway Ċ Ċ import Ġcom . t inder . sc ar let .* Ċ import Ġcom . t inder . sc ar let . utils . getRaw Type Ċ import Ġcom . t inder . sc ar let . websocket . Shutdown Reason Ċ import Ġcom . t inder . sc ar let . websocket . okhttp . Ok Http WebSocket Ċ import Ġorg . t esser akt . disk ord in . gateway . json . WebSocket Event Ċ import Ġjava . lang . reflect . Type Ċ Ċ object ĠWebSocket Event Adapter Ġ: ĠProtocol Specific Event Adapter Ġ{ ĊĠĠĠ Ġobject ĠFactory Ġ: ĠProtocol Specific Event Adapter . Factory Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġcreate ( type : ĠType , Ġannotations : ĠArray < Annotation >): ĠWebSocket Event Adapter Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġreceiving Type Ġ= Ġtype . getRaw Type () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrequire ( WebSocket Event Wrap :: class . java . isAssignableFrom ( re ceiving Type )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Only Ġsubclasses Ġof ĠWebSocket Event Ġare Ġsupported " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠWebSocket Event Adapter ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġfrom Event ( event : ĠProtocol Event ): ĠProtocol Specific Event Ġ= Ġwhen Ġ( event ) Ġ{ ĊĠĠĠĠĠĠĠ Ġis ĠProtocol Event . On Opened Ġ-> ĠWebSocket Event . Connection Opened . wrap () ĊĠĠĠĠĠĠĠ Ġis ĠProtocol Event . On Message Received Ġ-> ĠWebSocket Event . Message Received ( event . message ()). wrap () ĊĠĠĠĠĠĠĠ Ġis ĠProtocol Event . On Message Deliver ed Ġ-> ĠWebSocket Event . Message Received ( event . message ()). wrap () ĊĠĠĠĠĠĠĠ Ġis ĠProtocol Event . On Closing Ġ-> Ġevent . response . to Event (). wrap () ĊĠĠĠĠĠĠĠ Ġis ĠProtocol Event . On Closed Ġ-> ĠWebSocket Event . Connection Closed . wrap () ĊĠĠĠĠĠĠĠ Ġis ĠProtocol Event . On Failed Ġ-> ĠWebSocket Event . Connection Failed ( event . throwable Ġ?: ĠThrowable (" UNKNOWN ")). wrap () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠProtocol . Close Response . to Event (): ĠWebSocket Event Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( code , Ġreason ) Ġ= Ġ( this Ġas ? ĠOk Http WebSocket . Close Response )?. shutdown Reason Ġ?: ĠShutdown Reason . GR ACE FUL ĊĠĠĠĠĠĠĠ Ġreturn ĠWebSocket Event . Connection Closing ( code . to Short (), Ġreason ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ @ Jvm Inline Ċ value Ġclass ĠWebSocket Event Wrap ( val Ġevent : ĠWebSocket Event ) Ġ: ĠProtocol Specific Event Ċ Ċ fun ĠWebSocket Event . wrap () Ġ= ĠWebSocket Event Wrap ( this ) Ċ fun ĠWebSocket Event Wrap . unwrap () Ġ= Ġevent Ċ Ċ operator Ġfun ĠMessage . invoke () Ġ= Ġwhen Ġ( this ) Ġ{ ĊĠĠĠ Ġis ĠMessage . Text Ġ-> Ġorg . t esser akt . disk ord in . gateway . json . Message . Text ( this . value ) ĊĠĠĠ Ġis ĠMessage . Bytes Ġ-> Ġorg . t esser akt . disk ord in . gateway . json . Message . Bytes ( this . value ) Ċ } Ċ Ċ operator Ġfun Ġorg . t esser akt . disk ord in . gateway . json . Message . invoke () Ġ= Ġwhen Ġ( this ) Ġ{ ĊĠĠĠ Ġis Ġorg . t esser akt . disk ord in . gateway . json . Message . Text Ġ-> ĠMessage . Text ( this . message ) ĊĠĠĠ Ġis Ġorg . t esser akt . disk ord in . gateway . json . Message . Bytes Ġ-> ĠMessage . Bytes ( this . message ) Ċ }