示例#1
0
        //
        // TODO
        //
        // User-related:    INVITE KILL QUIT
        // Channel-related: KICK NICK PART
        //
        //
        // Constructors
        //
        public Server( )
        {
            _messageFilters = new List<FilterAndHandler> {
                new FilterAndHandler( ( m ) => ( m.Verb == "001"   ), HandleRplWelcome   ),
                new FilterAndHandler( ( m ) => ( m.Verb == "004"   ), HandleRplMyInfo    ),
                new FilterAndHandler( ( m ) => ( m.Verb == "005"   ), HandleRplISupport  ),
                new FilterAndHandler( ( m ) => ( m.Verb == "311"   ), HandleRplWhoisUser ),
                new FilterAndHandler( ( m ) => ( m.Verb == "352"   ), HandleRplWhoReply  ),
                new FilterAndHandler( ( m ) => ( m.Verb == "353"   ), HandleRplNamReply  ),
                new FilterAndHandler( ( m ) => ( m.Verb == "375"   ), HandleRplMotdStart ),
                new FilterAndHandler( ( m ) => ( m.Verb == "422"   ), HandleErrNoMotd    ),
                new FilterAndHandler( ( m ) => ( m.Verb == "ERROR" ), HandleError        ),
                new FilterAndHandler( ( m ) => ( m.Verb == "JOIN"  ), HandleJoin         ),
                new FilterAndHandler( ( m ) => ( m.Verb == "PING"  ), HandlePing         ),

                new FilterAndHandler( ( m ) => ( m.Verb == "NOTICE" && m.Origin.IsServerName ), HandleServerNotice ),
            };

            _iSupportHandler = new ISupportHandler( _supportedFeatures );
            _serverInformation = _iSupportHandler.ServerInformation;
        }
        // Events
        // Constructors
        public ISupportHandler( )
        {
            ServerInformation = new ServerInformation( );

            _booleanFeatureKeyParsers = new Dictionary<string, Action>( );
            _stringFeatureKeyParsers = new Dictionary<string, Action<string>>( );

            foreach ( var method in GetType( ).GetMethods( BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.InvokeMethod ) ) {
                var bfaType = typeof( BooleanFeatureAttribute );
                foreach ( var attr in method.GetCustomAttributes( bfaType, true ) ) {
                    var booleanFeature = (BooleanFeatureAttribute) attr;
                    var m = method;
                    _booleanFeatureKeyParsers.Add( booleanFeature.Key, ( ) => m.Invoke( this, null ) );
                }

                var sfaType = typeof( StringFeatureAttribute );
                foreach ( var attr in method.GetCustomAttributes( sfaType, true ) ) {
                    var stringFeature = (StringFeatureAttribute) attr;
                    var m = method;
                    _stringFeatureKeyParsers.Add( stringFeature.Key, _ => m.Invoke( this, new object[ ] { _ } ) );
                }
            }
        }
示例#3
0
        //
        // Constructors
        //
        //
        // TODO
        //
        // User-related:    INVITE KILL QUIT
        // Channel-related: KICK NICK PART
        //
        public Server( )
        {
            _verbsToRegister = new Dictionary<string, EventHandler<MessageEventArgs>> {
                { "001",        HandleRplWelcome        },
                { "002",        HandleRplYourHost       },
                { "003",        HandleRplCreated        },
                { "004",        HandleRplMyInfo         },
                { "005",        HandleRplISupport       },
                { "311",        HandleRplWhoisUser      },
                { "324",        HandleRplChannelModeIs  },
                { "329",        HandleRplCreationTime   },
                { "332",        HandleRplTopic          },
                { "333",        HandleRplTopicWhoTime   },
                { "352",        HandleRplWhoReply       },
                { "353",        HandleRplNamReply       },
                { "375",        HandleRplMotdStart      },

                { "CAP",        HandleCap               },
                { "ERROR",      HandleError             },
                { "JOIN",       HandleJoin              },
                { "MODE",       HandleMode              },
                { "NOTICE",     HandleNotice            },
                { "PING",       HandlePing              },
                { "PRIVMSG",    HandlePrivMsg           },
                { "QUIT",       HandleQuit              },

                { string.Empty, HandleUnknown           },
            };

            _iSupportHandler = new ISupportHandler( _supportedFeatures );
            _serverInformation = _iSupportHandler.ServerInformation;
        }