Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b1596e12e | |||
| f3ad798d0e | |||
| ec5fc33af1 | |||
| 9e112ec3f9 |
+7
-6
@@ -5,7 +5,7 @@ import PackageDescription
|
||||
let package = Package(
|
||||
name: "SlackKit",
|
||||
platforms: [
|
||||
.macOS(.v10_10), .iOS(.v10), .tvOS(.v10)
|
||||
.macOS(.v10_15), .iOS(.v10), .tvOS(.v10)
|
||||
],
|
||||
products: [
|
||||
.library(name: "SlackKit", targets: ["SlackKit"]),
|
||||
@@ -16,9 +16,9 @@ let package = Package(
|
||||
.library(name: "SKWebAPI", targets: ["SKWebAPI"])
|
||||
],
|
||||
dependencies: [
|
||||
.package(name: "Swifter", url: "https://github.com/httpswift/swifter.git", .upToNextMinor(from: "1.5.0")),
|
||||
.package(name: "WebSocket", url: "https://github.com/vapor/websocket", .upToNextMinor(from: "1.1.2")),
|
||||
.package(name: "Starscream", url: "https://github.com/daltoniam/Starscream", .upToNextMinor(from: "4.0.4"))
|
||||
.package(url: "https://github.com/httpswift/swifter", from: .init(1, 5, 0)),
|
||||
.package(url: "https://github.com/vapor/websocket-kit", from: .init(2, 5, 0)),
|
||||
.package(url: "https://github.com/daltoniam/Starscream", from: .init(4, 0, 4)),
|
||||
],
|
||||
targets: [
|
||||
.target(name: "SlackKit",
|
||||
@@ -34,11 +34,12 @@ let package = Package(
|
||||
"SKCore",
|
||||
"SKWebAPI",
|
||||
.product(name: "Starscream", package: "Starscream", condition: .when(platforms: [.macOS, .iOS, .tvOS])),
|
||||
.product(name: "WebSocket", package: "WebSocket", condition: .when(platforms: [.macOS, .linux])),
|
||||
.product(name: "WebSocketKit", package: "websocket-kit", condition: .when(platforms: [.macOS, .linux])),
|
||||
],
|
||||
path: "SKRTMAPI/Sources"),
|
||||
.target(name: "SKServer",
|
||||
dependencies: ["SKCore", "SKWebAPI", "Swifter"],
|
||||
dependencies: ["SKCore", "SKWebAPI",
|
||||
.product(name: "Swifter", package: "swifter")],
|
||||
path: "SKServer/Sources"),
|
||||
.target(name: "SKWebAPI",
|
||||
dependencies: ["SKCore"],
|
||||
|
||||
@@ -1,20 +1,6 @@
|
||||
<p align="center"><img src="https://cloud.githubusercontent.com/assets/8311605/24083714/e921a0d4-0cb2-11e7-8384-d42113ef5056.png" alt="SlackKit" width="500"/></p>
|
||||
# **This library is no longer under active development.**
|
||||
|
||||
[](https://dev.azure.com/pzignego/SlackKit/_build/latest?definitionId=2&branchName=master)
|
||||
|
||||

|
||||

|
||||

|
||||
[](https://github.com/apple/swift-package-manager)
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
[](https://cocoapods.org)
|
||||
|
||||
## SlackKit: Slack Apps in Swift
|
||||
### Description
|
||||
|
||||
SlackKit makes it easy to build Slack apps in Swift.
|
||||
|
||||
It's intended to expose all of the functionality of Slack's [Real Time Messaging API](https://api.slack.com/rtm) as well as the [web APIs](https://api.slack.com/web) that are accessible to [bot users](https://api.slack.com/bot-users). SlackKit also supports Slack’s [OAuth 2.0](https://api.slack.com/docs/oauth) flow including the [Add to Slack](https://api.slack.com/docs/slack-button) and [Sign in with Slack](https://api.slack.com/docs/sign-in-with-slack) buttons, [incoming webhooks](https://api.slack.com/incoming-webhooks), [slash commands](https://api.slack.com/slash-commands), and [message buttons](https://api.slack.com/docs/message-buttons).
|
||||
## SlackKit
|
||||
|
||||
### Installation
|
||||
|
||||
@@ -150,11 +136,3 @@ Don’t need the whole banana? Want more control over the low-level implementati
|
||||
|
||||
### Examples
|
||||
You can find the source code for several example applications [here](https://github.com/pvzig/SlackKit/tree/master/Examples).
|
||||
|
||||
### Tutorials
|
||||
- [Build a Slack Bot and Deploy to Heroku](https://medium.com/@pvzig/building-slack-bots-in-swift-b99e243e444c)
|
||||
|
||||
### Get In Touch
|
||||
Twitter: [@pvzig](https://twitter.com/pvzig)
|
||||
|
||||
Email: <peter@launchsoft.co>
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
|
||||
#if os(Linux) || os(macOS) && !COCOAPODS
|
||||
import Foundation
|
||||
import HTTP
|
||||
import WebSocket
|
||||
import NIO
|
||||
import WebSocketKit
|
||||
|
||||
// Builds with *Swift Package Manager ONLY*
|
||||
public class VaporEngineRTM: RTMWebSocket {
|
||||
@@ -34,7 +34,7 @@ public class VaporEngineRTM: RTMWebSocket {
|
||||
public weak var delegate: RTMDelegate?
|
||||
// Websocket
|
||||
private var websocket: WebSocket?
|
||||
private var futureWebsocket: Future<WebSocket>?
|
||||
private var futureWebsocket: EventLoopFuture<Void>?
|
||||
|
||||
public required init() {}
|
||||
|
||||
@@ -43,14 +43,10 @@ public class VaporEngineRTM: RTMWebSocket {
|
||||
fatalError("ERROR - Cannot extract host from '\(url.absoluteString)'")
|
||||
}
|
||||
|
||||
let scheme: HTTPScheme = url.scheme == "wss" ? .wss : .ws
|
||||
futureWebsocket = HTTPClient.webSocket(
|
||||
scheme: scheme,
|
||||
hostname: host,
|
||||
path: url.path,
|
||||
on: eventLoopGroup
|
||||
)
|
||||
.do(didConnect)
|
||||
futureWebsocket = WebSocketClient(eventLoopGroupProvider: .shared(eventLoopGroup))
|
||||
.connect(scheme: url.scheme ?? "ws", host: host, port: 8080, path: url.path, query: nil, headers: [:]) { [weak self] webSocket in
|
||||
self?.didConnect(websocket: webSocket)
|
||||
}
|
||||
}
|
||||
|
||||
func didConnect(websocket: WebSocket) {
|
||||
@@ -62,17 +58,14 @@ public class VaporEngineRTM: RTMWebSocket {
|
||||
self.delegate?.receivedMessage(text)
|
||||
}
|
||||
|
||||
websocket.onError { ws, error in
|
||||
|
||||
}
|
||||
|
||||
websocket.onCloseCode { closeCode in
|
||||
self.delegate?.disconnected()
|
||||
}
|
||||
websocket.onClose
|
||||
.whenComplete { [weak self] _ in
|
||||
self?.delegate?.disconnected()
|
||||
}
|
||||
}
|
||||
|
||||
public func disconnect() {
|
||||
websocket?.close()
|
||||
_ = websocket?.close()
|
||||
websocket = nil
|
||||
futureWebsocket = nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user