This is a very simple WebSocket based IRC WebClient/Server.
It contains a small chat-webapp as the frontend (a single-page webapp written in plain JavaScript, not frameworks), it contains a WebSocket/IRC bridge using the SwiftNIO IRC client module, and a small HTTP server which delivers the webapp and serves as a websocket endpoint.
This WebClient is a regular Swift package and can be imported in other Swift servers!
On the surface it is a very simple chat webapp, with basic support for channels and direct messages:
Sometimes a live demo installation is running on http://irc.noze.io/. We probably have to shut it down once abuse starts to take place :-) If it doesn't run and you want to play with it, just install it locally, it is a matter of minutes using MiniIRCd.
This module contains the middlepart, the webserver. It serves two purposes:
βββββββββββββββββββββββββ
HTML β βββββββββββββββββββ β
ββββββββJSβββββββββββΌβββ NIO HTTP Server β β
β β βββββββββββββββββββ β
β β β β
βΌ β Upgrades β
ββββββββββββββββ β Connection β
β β β β β
β WebBrowser β β βΌ β ββββββββββββββββ
β β WebSocket β βββββββββββββββββββ β β β
β JavaScript ββββββJSONββββΌββΆβ NIO WebSocket ββββΌβIRCβββΆβ IRC Server β
β WebApp β β βββββββββββββββββββ β β β
β β β WebServer β ββββββββββββββββ
ββββββββββββββββ βββββββββββββββββββββββββ
The JavaScript web app is embedded into the compiled Swift module (using a Makefile all the resources are bundled together into a single Swift source file). Yet it also works as a standalone web application (you can drag the Client.html into your browser.
The client app is located in Sources/IRCWebClient/WebApp.
An example Package.swift
importing the necessary modules:
// swift-tools-version:5.0
import PackageDescription
let package = Package(
name: "MyOwnIRCServer",
dependencies: [
.package(url: "https://github.com/NozeIO/swift-nio-irc-webclient.git",
from: "0.7.0")
],
targets: [
.target(name: "MyIRCServer",
dependencies: [ "IRCServer", "IRCWebClient" ])
]
)
let webServer = IRCWebClientServer()
webServer.listen()
Check the Configuration object for the supported configuration options.
One can configure three connection parameters:
Brought to you by ZeeZide. We like feedback, GitHub stars, cool contract work, presumably any form of praise you can think of.
link |
Stars: 18 |
Last commit: 3 years ago |
The IRC client lib was moved to a standalone package to not spam the protocol implementation.
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics