Exemplo n.º 1
0
  public static void main(String[] args) {
    int serverPort = 12345;
    IRCServer ircServer = new IRCServer(serverPort);

    System.out.println("Waiting for the client");
    ircServer.listen();
  }
  public void serverConnected(Server server) {
    for (int i = 0; i < _start.getCommands().length; i++) {
      String cmd = _start.getCommands()[i];
      if ((cmd.startsWith("/")) && (server instanceof IRCServer))
        ((IRCServer) server).getStatus().sendString(_start.getCommands()[i]);
      else server.execute(_start.getCommands()[i]);
    }

    Enumeration<Plugin> enum1 = _plugins.elements();
    while (enum1.hasMoreElements()) {
      Plugin plugin = (Plugin) enum1.nextElement();
      plugin.serverConnected(server);
    }
  }
Exemplo n.º 3
0
  @Override
  protected void run(IRCServer server, IRCMessage message) throws IOException {
    IRCMessage reply = new IRCMessage("PONG", message.getParameters());

    server.sendMessage(reply);
  }
  /** Init the application. */
  public synchronized void init() {
    loadPlugin(_interface);

    String[] plugins = _start.getPlugins();
    for (int i = 0; i < plugins.length; i++) loadPlugin(plugins[i]); // uses string

    _interface.addIRCInterfaceListener(this);
    if (_container == null) {
      _frame = new JFrame();
      _frame.addWindowListener(this);
      if (_interface.getComponent() != null) _frame.add(_interface.getComponent());
      _frame.setFont(new Font("", Font.PLAIN, 12));
      _frame.setSize(640, 400);
      _frame.setVisible(true);
    } else {
      _frame = null;
      _container.removeAll();
      _container.setLayout(new GridLayout(1, 1));
      if (_interface.getComponent() != null) _container.add(_interface.getComponent());
    }

    _inter = new CTCPInterpretor(_ircConfiguration, _defaultSource.getInterpretor(), this);
    _inter.addLast(_interface.getInterpretor());

    if (_ircConfiguration.getB("useidentserver")) {
      try {
        _ident = new IdentWrapper(_ircConfiguration);
        Exception e = _ident.start(_start.getName(), this);
        if (e != null) {
          _defaultSource.report(
              "\3" + "6" + "*** " + getText(IRCTextProvider.IDENT_FAILED_LAUNCH, e.getMessage()));
        }
      } catch (Throwable ex) {
        _ircConfiguration.internalError("ident error", ex, "*****@*****.**");
      }
    } else {
      _ident = null;
    }

    String[] init = _ircConfiguration.getInitialization();
    for (int i = 0; i < init.length; i++) _defaultSource.sendString(init[i]);

    IRCServer server =
        new IRCServer(
            _ircConfiguration,
            this,
            _start.getNick(),
            _start.getAltNick(),
            _start.getName(),
            _start.getAlias());
    server.setServers(_start.getHost(), _start.getPort(), _start.getPass());

    newServer(server, _ircConfiguration.getB("autoconnection"));

    if (_start.getSmileysSupport() == false) {
      _ircConfiguration.resetSmileyTable(); // _defaultSource.sendString("/dsmileys");
      System.out.println("Smileys should be DISABLED!");
    } else {
      _ircConfiguration.restoreSmileyTable();
      System.out.println("Smileys should be ACTIVE!");
    }
    requestSourceFocus();
  }