|
@@ -87,14 +87,15 @@ interface IrcClient {
|
87
|
87
|
// TODO: How should alternative nicknames work?
|
88
|
88
|
// TODO: Should IRC Client take a pool of servers and rotate through, or make the caller do that?
|
89
|
89
|
// TODO: Should there be a default profile?
|
90
|
|
-@KtorExperimentalAPI
|
91
|
|
-@ExperimentalCoroutinesApi
|
92
|
90
|
class IrcClientImpl(private val server: Server, override val profile: Profile) : IrcClient, CoroutineScope {
|
93
|
91
|
|
94
|
92
|
private val log by logger()
|
95
|
93
|
|
|
94
|
+ @ExperimentalCoroutinesApi
|
96
|
95
|
override val coroutineContext = GlobalScope.newCoroutineContext(Dispatchers.IO)
|
97
|
96
|
|
|
97
|
+ @ExperimentalCoroutinesApi
|
|
98
|
+ @KtorExperimentalAPI
|
98
|
99
|
internal var socketFactory: (CoroutineScope, String, Int, Boolean) -> LineBufferedSocket = ::KtorLineBufferedSocket
|
99
|
100
|
|
100
|
101
|
override val serverState = ServerState(profile.initialNick, server.host)
|
|
@@ -115,6 +116,7 @@ class IrcClientImpl(private val server: Server, override val profile: Profile) :
|
115
|
116
|
override fun connect() {
|
116
|
117
|
check(!connecting.getAndSet(true))
|
117
|
118
|
|
|
119
|
+ @Suppress("EXPERIMENTAL_API_USAGE")
|
118
|
120
|
with(socketFactory(this, server.host, server.port, server.tls)) {
|
119
|
121
|
// TODO: Proper error handling - what if connect() fails?
|
120
|
122
|
socket = this
|