|
@@ -56,14 +56,46 @@ other than using an insecure connection.
|
56
|
56
|
This is an issue with the Java standard library. You can change its behaviour by
|
57
|
57
|
defining the system property `java.net.preferIPv6Addresses` to `true`, e.g. by
|
58
|
58
|
running Java with `-Djava.net.preferIPv6Addresses=true` or calling
|
59
|
|
-`System.setProperty("java.net.preferIPv6Addresses","true");` in code.
|
60
|
|
-
|
61
|
|
-## Contributing
|
|
59
|
+`System.setProperty("java.net.preferIPv6Addresses","true");` in code.
|
|
60
|
+
|
|
61
|
+## Developing KtIrc
|
|
62
|
+
|
|
63
|
+### Lifecycle of a message
|
|
64
|
+
|
|
65
|
+![architecture diagram](docs/sequence.png)
|
|
66
|
+
|
|
67
|
+The `LineBufferedSocket` class receives bytes from the IRC server. Whenever it
|
|
68
|
+encounters a complete line (terminated by a `CR`, `LF` or `CRLF`), it passes it
|
|
69
|
+to the `IrcClient` as a `ByteArray`. The `MessageParser` breaks up the line
|
|
70
|
+into its component parts (tags, prefixes, commands, and parameters) and returns
|
|
71
|
+them as an `IrcMessage`.
|
|
72
|
+
|
|
73
|
+The `IrcMessage` is given to the `MessageHandler`, which tries to find a
|
|
74
|
+processor that can handle the command in the message. The processor's job is
|
|
75
|
+to convert the message into an `IrcEvent` subclass. Processors do not get
|
|
76
|
+given any contextual information or state, their job is simply to convert
|
|
77
|
+the message as received into an event.
|
|
78
|
+
|
|
79
|
+The events are returned to the `MessageHandler` which then passes them on
|
|
80
|
+to all registered event handlers. The job of the event handlers is twofold:
|
|
81
|
+firstly, use the events to update the state of KtIrc (for example, after
|
|
82
|
+receiving a `JOIN` message, the `ChannelStateHandler` will add the user
|
|
83
|
+to the list of users in the channel, while the `UserStateHandler` may update
|
|
84
|
+the user's hostname if we hadn't previously seen it). Secondly, the event
|
|
85
|
+handlers may themselves raise events. This is useful for higher-order
|
|
86
|
+events such as `ServerReady` that depend on a variety of factors and
|
|
87
|
+states.
|
|
88
|
+
|
|
89
|
+All the generated events (from processors or from event handlers) are
|
|
90
|
+passed to the `IrcClient`, which in turn passes them to the library
|
|
91
|
+user via the delegates passed to the `onEvent` method.
|
|
92
|
+
|
|
93
|
+### Contributing
|
62
|
94
|
|
63
|
95
|
Contributing is welcomed and encouraged! Please try to add unit tests for new features,
|
64
|
96
|
and maintain a code style consistent with the existing code.
|
65
|
97
|
|
66
|
|
-## Licence
|
|
98
|
+### Licence
|
67
|
99
|
|
68
|
100
|
The code in this repository is released under the MIT licence. See the
|
69
|
|
-[LICENCE](LICENCE) file for more info.
|
|
101
|
+[LICENCE](LICENCE) file for more info.
|