Compare commits

..

4 Commits

Author SHA1 Message Date
Peter Zignego 8b1596e12e Update README.md 2022-12-02 08:54:50 -05:00
Peter Zignego f3ad798d0e Update README.md 2022-11-30 19:55:34 -05:00
Peter Zignego ec5fc33af1 Update README.md 2022-11-30 19:55:12 -05:00
Go Takagi 9e112ec3f9 Update websocket-kit 2.5.0 (#212)
* Bump websocket-kit to 2.5.0

* Migrate breaking api changes
2022-07-18 22:27:02 -04:00
3 changed files with 21 additions and 49 deletions
+7 -6
View File
@@ -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"],
+2 -24
View File
@@ -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.**
[![Build Status](https://dev.azure.com/pzignego/SlackKit/_apis/build/status/pvzig.SlackKit?branchName=master)](https://dev.azure.com/pzignego/SlackKit/_build/latest?definitionId=2&branchName=master)
![Swift Version](https://img.shields.io/badge/Swift-5-orange.svg)
![Plaforms](https://img.shields.io/badge/Platforms-macOS,_iOS,_tvOS,_Linux-lightgrey.svg)
![License MIT](https://img.shields.io/badge/License-MIT-lightgrey.svg)
[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg)](https://github.com/Carthage/Carthage)
[![CocoaPods compatible](https://img.shields.io/badge/CocoaPods-compatible-brightgreen.svg)](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 Slacks [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 @@ Dont 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
}