Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor channels names(only readability fix) #390

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions src/connector/pusher-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,41 +63,39 @@ export class PusherConnector extends Connector {
* Get a private channel instance by name.
*/
privateChannel(name: string): PusherChannel {
if (!this.channels['private-' + name]) {
this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
name = 'private-' + name;

if (!this.channels[name]) {
this.channels[name] = new PusherPrivateChannel(this.pusher, name, this.options);
}

return this.channels['private-' + name];
return this.channels[name];
}

/**
* Get a private encrypted channel instance by name.
*/
encryptedPrivateChannel(name: string): PusherChannel {
if (!this.channels['private-encrypted-' + name]) {
this.channels['private-encrypted-' + name] = new PusherEncryptedPrivateChannel(
this.pusher,
'private-encrypted-' + name,
this.options
);
name = 'private-encrypted-' + name;

if (!this.channels[name]) {
this.channels[name] = new PusherEncryptedPrivateChannel(this.pusher, name, this.options);
}

return this.channels['private-encrypted-' + name];
return this.channels[name];
}

/**
* Get a presence channel instance by name.
*/
presenceChannel(name: string): PresenceChannel {
if (!this.channels['presence-' + name]) {
this.channels['presence-' + name] = new PusherPresenceChannel(
this.pusher,
'presence-' + name,
this.options
);
name = 'presence-' + name;

if (!this.channels[name]) {
this.channels[name] = new PusherPresenceChannel(this.pusher, name, this.options);
}

return this.channels['presence-' + name];
return this.channels[name];
}

/**
Expand Down
20 changes: 10 additions & 10 deletions src/connector/socketio-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,26 @@ export class SocketIoConnector extends Connector {
* Get a private channel instance by name.
*/
privateChannel(name: string): SocketIoPrivateChannel {
if (!this.channels['private-' + name]) {
this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
name = 'private-' + name;

if (!this.channels[name]) {
this.channels[name] = new SocketIoPrivateChannel(this.socket, name, this.options);
}

return this.channels['private-' + name] as SocketIoPrivateChannel;
return this.channels[name] as SocketIoPrivateChannel;
}

/**
* Get a presence channel instance by name.
*/
presenceChannel(name: string): SocketIoPresenceChannel {
if (!this.channels['presence-' + name]) {
this.channels['presence-' + name] = new SocketIoPresenceChannel(
this.socket,
'presence-' + name,
this.options
);
name = 'presence-' + name;

if (!this.channels[name]) {
this.channels[name] = new SocketIoPresenceChannel(this.socket, name, this.options);
}

return this.channels['presence-' + name] as SocketIoPresenceChannel;
return this.channels[name] as SocketIoPresenceChannel;
}

/**
Expand Down
Loading