rm CustomChannel
This commit is contained in:
parent
1ce0aaf927
commit
bea6ab8e09
@ -1,6 +1,5 @@
|
|||||||
import PublicChannel from './channels/types/publicChannel';
|
import PublicChannel from './channels/types/publicChannel';
|
||||||
import PrivateChannel from './channels/types/privateChannel';
|
import PrivateChannel from './channels/types/privateChannel';
|
||||||
import CustomChannel from './channels/types/customChannel';
|
|
||||||
import PublicClient from './clients/types/publicClient';
|
import PublicClient from './clients/types/publicClient';
|
||||||
import PrivateClient from './clients/types/privateClient';
|
import PrivateClient from './clients/types/privateClient';
|
||||||
import CustomClient from './clients/types/customClient';
|
import CustomClient from './clients/types/customClient';
|
||||||
@ -17,8 +16,8 @@ class ChannelManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createChannel(data: any) {
|
createChannel(data: any) {
|
||||||
const channelExists: PublicChannel|PrivateChannel|CustomChannel|null = this.channelExists(data.channel);
|
const channelExists: PublicChannel|PrivateChannel|null = this.channelExists(data.channel);
|
||||||
let channel: PublicChannel|PrivateChannel|CustomChannel;
|
let channel: PublicChannel|PrivateChannel;
|
||||||
|
|
||||||
if (channelExists) {
|
if (channelExists) {
|
||||||
channel = channelExists;
|
channel = channelExists;
|
||||||
@ -43,7 +42,7 @@ class ChannelManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addClientToChannel(client: PublicClient|PrivateClient|CustomClient, channel_id: string) {
|
addClientToChannel(client: PublicClient|PrivateClient|CustomClient, channel_id: string) {
|
||||||
const channel: PrivateChannel|PrivateChannel|CustomChannel|null = this.channelExists(channel_id);
|
const channel: PrivateChannel|PrivateChannel|null = this.channelExists(channel_id);
|
||||||
|
|
||||||
if (channel) {
|
if (channel) {
|
||||||
channel.addClient(client);
|
channel.addClient(client);
|
||||||
@ -54,7 +53,7 @@ class ChannelManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateChannelContent(channel: PrivateChannel|PrivateChannel|CustomChannel, channelContent: JSON) {
|
updateChannelContent(channel: PrivateChannel|PrivateChannel, channelContent: JSON) {
|
||||||
if (channel) {
|
if (channel) {
|
||||||
channel.channelContent = channelContent;
|
channel.channelContent = channelContent;
|
||||||
return {status: 'success'};
|
return {status: 'success'};
|
||||||
@ -70,12 +69,10 @@ class ChannelManager {
|
|||||||
`attempting to create channel of type ${data.channel_type}, channel id: ${data.channel}...`
|
`attempting to create channel of type ${data.channel_type}, channel id: ${data.channel}...`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (data.channel_type === 'public') {
|
if (data.channel_type === 'private') {
|
||||||
return new PublicChannel(data.channel);
|
|
||||||
} else if (data.channel_type === 'private') {
|
|
||||||
return new PrivateChannel(data.channel);
|
return new PrivateChannel(data.channel);
|
||||||
} else {
|
} else {
|
||||||
return new CustomChannel(data.channel, data.custom);
|
return new PublicChannel(data.channel);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
import CustomClient from '../../clients/types/customClient';
|
|
||||||
import ChannelBase from '../channelBase';
|
|
||||||
|
|
||||||
class CustomChannel extends ChannelBase {
|
|
||||||
clients: CustomClient[] = [];
|
|
||||||
|
|
||||||
constructor(id: string, custom: any) {
|
|
||||||
super(id);
|
|
||||||
|
|
||||||
if (custom) {
|
|
||||||
this.broadcastConditions = custom.broadcastConditions;
|
|
||||||
this.channelContent = custom.channelContent;
|
|
||||||
this.explicitRemoval = custom.explicitRemoval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default CustomChannel;
|
|
@ -3,7 +3,6 @@ import ClientManager from '../clientManager';
|
|||||||
import ChannelManager from '../channelManager';
|
import ChannelManager from '../channelManager';
|
||||||
import PublicChannel from '../channels/types/publicChannel';
|
import PublicChannel from '../channels/types/publicChannel';
|
||||||
import PrivateChannel from '../channels/types/privateChannel';
|
import PrivateChannel from '../channels/types/privateChannel';
|
||||||
import CustomChannel from '../channels/types/customChannel';
|
|
||||||
|
|
||||||
const messageManager = require('../messageManager');
|
const messageManager = require('../messageManager');
|
||||||
const logger = require('../logger');
|
const logger = require('../logger');
|
||||||
@ -12,7 +11,7 @@ class ClientBase {
|
|||||||
ws: WebSocket;
|
ws: WebSocket;
|
||||||
data: any;
|
data: any;
|
||||||
id: number;
|
id: number;
|
||||||
channel: PublicChannel|PrivateChannel|CustomChannel|null;
|
channel: PublicChannel|PrivateChannel|null;
|
||||||
clientManager: ClientManager;
|
clientManager: ClientManager;
|
||||||
channelManager: ChannelManager;
|
channelManager: ChannelManager;
|
||||||
roles: string[];
|
roles: string[];
|
||||||
@ -68,7 +67,7 @@ class ClientBase {
|
|||||||
return this.data.client;
|
return this.data.client;
|
||||||
}
|
}
|
||||||
|
|
||||||
connectToChannel(channel: PublicChannel|PrivateChannel|CustomChannel) {
|
connectToChannel(channel: PublicChannel|PrivateChannel) {
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.ws.on('message', this.messageListener);
|
this.ws.on('message', this.messageListener);
|
||||||
this.ws.on('close', this.closeListener);
|
this.ws.on('close', this.closeListener);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user