Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions EventSource/EventSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public enum EventSourceState {
public protocol EventSourceProtocol {
var headers: [String: String] { get }

/// RetryTime: This can be changed remotly if the server sends an event `retry:`
/// RetryTime: This can be changed remotely if the server sends an event `retry:`
var retryTime: Int { get }

/// URL where EventSource will listen for events.
var url: URL { get }

/// The last event id received from server. This id is neccesary to keep track of the last event-id received to avoid
/// The last event id received from server. This id is necessary to keep track of the last event-id received to avoid
/// receiving duplicate events after a reconnection.
var lastEventId: String? { get }

Expand Down Expand Up @@ -52,7 +52,7 @@ public protocol EventSourceProtocol {
/// The server could have requested the disconnection or maybe a network layer error, wrong URL or any other
/// error. The callback receives as parameters the status code of the disconnection, if we should reconnect or not
/// following event source rules and finally the network layer error if any. All this information is more than
/// enought for you to take a decition if you should reconnect or not.
/// enough for you to take a decision if you should reconnect or not.
/// - Parameter onOpenCallback: callback
func onComplete(_ onComplete: @escaping ((Int?, Bool?, NSError?) -> Void))

Expand Down
8 changes: 4 additions & 4 deletions EventSource/EventStreamParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ final class EventStreamParser {

var searchRange = NSRange(location: 0, length: dataBuffer.length)
while let foundRange = searchFirstEventDelimiter(in: searchRange) {
// if we found a delimiter range that means that from the beggining of the buffer
// until the beggining of the range where the delimiter was found we have an event.
// The beggining of the event is: searchRange.location
// The lenght of the event is the position where the foundRange was found.
// if we found a delimiter range that means that from the beginning of the buffer
// until the beginning of the range where the delimiter was found we have an event.
// The beginning of the event is: searchRange.location
// The length of the event is the position where the foundRange was found.

let dataChunk = dataBuffer.subdata(
with: NSRange(location: searchRange.location, length: foundRange.location - searchRange.location)
Expand Down
2 changes: 1 addition & 1 deletion EventSourceTests/EventSourceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class EventSourceTests: XCTestCase {
}
}

func testDisconnet() {
func testDisconnect() {
eventSource.readyStateOpen()
eventSource.disconnect()

Expand Down
2 changes: 1 addition & 1 deletion EventSourceTests/EventTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class EventTests: XCTestCase {
XCTAssertEqual(event?.data, "")
}

func testEventDobleEmptyData() {
func testEventDoubleEmptyData() {
let eventsString = """
data
data
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ SSE Client written on Swift using NSURLSession.

This is an EventSource implementation written on Swift following the [W3C EventSource](http://www.w3.org/TR/eventsource/) document. If something is missing or not completely right open an issue and I'll work on it!

If you like the library please leave us a ★. That helps us to stay engaged on the mantainence!
If you like the library please leave us a ★. That helps us to stay engaged on the maintenance!

### Changes from version 2.2.1 to 3.0

I took some time to review all the forks, pull requests and issues opened on github. The main changes and complains I found were related to the connection and the `Last-Event-Id` handling.
I took some time to review all the forks, pull requests and issues opened on GitHub. The main changes and complains I found were related to the connection and the `Last-Event-Id` handling.

The changes on this version are:

- `EventSource` doesn't connect automatically anymore. It waits until `connect(lastEventId: String? = nil)` method is called. This method accepts a `lastEventId` which will be sent to the server upon connection.
- `EventSource` lets you call `disconnect()` whenever you want.
- `EventSource` doesn't store the `Last-Event-Id` anymore and you will have to take care of storing the `id` and sending using it or not in the `connect` method.
- `EventSource` doesn't reconnect at all. If a network layer error occurs (disconnection, timeout, etc) or if the server closes the connection you will have to take care to reconnect with the server.
- `EventSource` doesn't reconnect at all. If a network layer error occurs (disconnection, timeout, etc.) or if the server closes the connection you will have to take care to reconnect with the server.
- Modularization. This library has been around since `Swift 1.0` and started just as a way to learn the language. With this new version the whole code has been improved, commented and fully tested to make it easier to track problems and extend in the future.

### How to use it?
Expand Down Expand Up @@ -77,13 +77,13 @@ import IKEventSource
#### Swift API:

```swift
/// RetryTime: This can be changed remotly if the server sends an event `retry:`
/// RetryTime: This can be changed remotely if the server sends an event `retry:`
var retryTime: Int { get }

/// URL where EventSource will listen for events.
var url: URL { get }

/// The last event id received from server. This id is neccesary to keep track of the last event-id received to avoid
/// The last event id received from server. This id is necessary to keep track of the last event-id received to avoid
/// receiving duplicate events after a reconnection.
var lastEventId: String? { get }

Expand Down Expand Up @@ -112,7 +112,7 @@ func onOpen(_ onOpenCallback: @escaping (() -> Void))
/// The server could have requested the disconnection or maybe a network layer error, wrong URL or any other
/// error. The callback receives as parameters the status code of the disconnection, if we should reconnect or not
/// following event source rules and finally the network layer error if any. All this information is more than
/// enought for you to take a decition if you should reconnect or not.
/// enough for you to take a decision if you should reconnect or not.
/// - Parameter onOpenCallback: callback
func onComplete(_ onComplete: @escaping ((Int?, Bool?, NSError?) -> Void))

Expand Down