forked from HadoukenIO/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RUN-4677 - Channel lifecycle (HadoukenIO#203)
* disconnect and destroy * undo gruntfile * lifecycle calls * add error messages for timing issue on destroy and disconnect
- Loading branch information
Showing
4 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
import { ChannelBase, ProviderIdentity } from './channel'; | ||
import Transport from '../../../transport/transport'; | ||
|
||
type DisconnectionListener = (providerIdentity: ProviderIdentity) => any; | ||
|
||
export class ChannelClient extends ChannelBase { | ||
private disconnectListener: DisconnectionListener; | ||
|
||
constructor(providerIdentity: ProviderIdentity, send: Transport['sendAction']) { | ||
super(providerIdentity, send); | ||
this.disconnectListener = () => undefined; | ||
} | ||
|
||
public async dispatch(action: string, payload?: any): Promise<any> { | ||
return this.send(this.providerIdentity, action, payload); | ||
} | ||
|
||
public onDisconnection(listener: DisconnectionListener): void { | ||
this.disconnectListener = listener; | ||
} | ||
|
||
public async disconnect(): Promise<void> { | ||
const { channelName } = this.providerIdentity; | ||
await this.sendRaw('disconnect-from-channel', { channelName }); | ||
const { channelId } = this.providerIdentity; | ||
this.removeChannel(channelId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters