Esempio n. 1
0
        public IrcConnection Connect( IrcConnectionID id )
        {
            var server = this.settings.Servers.FirstOrDefault( (s) => UriToConnectionId(s.Uri) == id ) ?? this.settings.DefaultServerSettings;

            var p = new IrcConnectParams()
                { To   = id
                , User =
                    { Host     = server.Userhost
                    , RealName = server.Realname
                    , ID       = server.Username
                    , Nick     = server.Nickname
                    }
                , Encoding = Encoding.UTF8
                , Password = server.Password
                , Channels = server.Channels.Select( (s) => s.Name ).ToArray()
                };

            IrcConnection connection;
            if ( !Connections.ContainsKey(id) ) {
                connection = new IrcConnection(p,Listeners);
                Connections.Add(id,connection);
            } else {
                connection = Connections[id];
            }
            return connection;
        }
Esempio n. 2
0
        public void Part( string url )
        {
            var uri = new UriBuilder(url);
            if ( uri.Path.Length <= 1 ) throw new UriFormatException( "Expected a URI with a channel" );

            var connid = new IrcConnectionID()
                { Hostname = uri.Host
                , Port     = uri.Port == -1 ? (int?)null : uri.Port
                , SSL      = uri.Scheme == "ircs"
                };
            var chan = "#"+uri.Path.Substring(1);
            if ( !Connections.ContainsKey(connid) ) throw new Exception( "Not connected to " + url );

            Connections[connid].Part(chan);
        }