Class: Net::IRC::Server

### Home Classes Methods

### In Files

- lib/net/irc/server.rb

### Parent

Object

### Namespace

- CLASS Net::IRC::Server::Session

### Methods

- ::new
- #finish
- #start

### Files

- README

### Class/Module Index

Quicksearch

- Net
- Net::IRC
- Net::IRC::Client
- Net::IRC::Client::ChannelManager
- Net::IRC::IRCException
- Net::IRC::Message
- Net::IRC::Message::InvalidMessage
- Net::IRC::Message::ModeParser
- Net::IRC::Message::ServerConfig
- Net::IRC::Prefix
- Net::IRC::Server
- Net::IRC::Server::Session
- Object

No matching classes.

# Net::IRC::Server

### Attributes

sessions[RW]
state[RW]

Server global state for accessing Server::Session

### Public Class Methods

new(host, port, session_class, opts={}) click to toggle source

    # File lib/net/irc/server.rb, line 6
    def initialize(host, port, session_class, opts={})
            @host          = host
            @port          = port
            @session_class = session_class
            @opts          = OpenStruct.new(opts)
            @sessions      = []
            @state         = {}
    end

### Public Instance Methods

finish() click to toggle source

Close all sessions.

    # File lib/net/irc/server.rb, line 41
    def finish
            Thread.exclusive do
                    @accept.kill
                    begin
                            @serv.close
                    rescue
                    end
                    @sessions.each do |s|
                            s.finish
                    end
            end
    end

start() click to toggle source

Start server loop.

    # File lib/net/irc/server.rb, line 16
    def start
            @serv = TCPServer.new(@host, @port)
            @log  = @opts.logger || Logger.new($stdout)
            @log.info "Host: #{@host} Port:#{@port}"
            @accept = Thread.start do
                    loop do
                            Thread.start(@serv.accept) do |s|
                                    begin
                                            @log.info "Client connected, new session starting..."
                                            s = @session_class.new(self, s, @log, @opts)
                                            @sessions << s
                                            s.start
                                    rescue Exception => e
                                            puts e
                                            puts e.backtrace
                                    ensure
                                            @sessions.delete(s)
                                    end
                            end
                    end
            end
            @accept.join
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.