import ClientBase from '../../clients/clientBase';
import MHSClient from '../../clients/sites/mhsClient';
import ChannelBase from '../channelBase';

var logger = require('../../logger');

class MHSChannel extends ChannelBase {
  broadcastMessage(from: ClientBase|MHSClient|null, message: string) {
    for (let client of this.clients) {
      if (client != from && client.data.user_type == 'teacher') {
        client.ws.send(message);
        logger.accessLog.info(`sent to ${client.id}: `, {message: message});
      } else {
        logger.accessLog.info(`client is same as sender: ${client.id} - `, {message: message});
      }
    }

    return {'status': 'success', 'message': `message broadcast complete`};
  }
};

module.exports = MHSChannel;
export default MHSChannel;
