Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

Commit

Permalink
Default port is 80, Transport, WebSocket (Close #5)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardopereira committed Jun 9, 2015
1 parent d50da33 commit 01176d8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Source/Extensions/NSURL+TrailingSlash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ internal extension NSURL {
}

var relativeURL: NSURL? {
return NSURL(string: "\(self.scheme!)://\(self.host!):\(self.port!)")
if let port = self.port {
return NSURL(string: "\(self.scheme!)://\(self.host!):\(port)")
}
else {
return NSURL(string: "\(self.scheme!)://\(self.host!)")
}
}

}
12 changes: 11 additions & 1 deletion Source/SocketIOWebSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Foundation
class SocketIOWebSocket: SocketIOTransport, WebSocketDelegate {

private var socket: WebSocket!
private let defaultPort = 80

private var nsp: String {
return delegate.options.namespace
Expand All @@ -26,7 +27,16 @@ class SocketIOWebSocket: SocketIOTransport, WebSocketDelegate {
return
}

if let scheme = hostUrl.scheme, let host = hostUrl.host, let port = hostUrl.port {
// Check current port
let port: Int
if let hostPort = hostUrl.port {
port = hostPort.integerValue
}
else {
port = defaultPort
}

if let scheme = hostUrl.scheme, let host = hostUrl.host {
// Establish connection
if scheme.lowercaseString == "http" {
// Standard
Expand Down

0 comments on commit 01176d8

Please sign in to comment.