 import SwiftWebSocket
 import Wrap
 
-public typealias SocketState = WebSocketReadyState
+public typealias SocketState = SwiftWebSocket.WebSocketReadyState
 
+/**
+*  @author Michael MacCallum, 16-05-16
+*
+*  <#Description#>
+*
+*  @since <#1.0#>
+*/
 public final class Socket {
 	public private(set) var socket: WebSocket?
 	public let heartbeatInterval: NSTimeInterval
+	public var reconnectInterval: NSTimeInterval
 	public let url: NSURL
 	public var reconnectOnError = true
+
+	public var onSocketOpen: (() -> Void)?
+	public var onSocketError: ((code: Int, reason: String, wasClean: Bool, error: NSError?) -> Void)?
+	public var onSocketClose: ((code: Int, reason: String, wasClean: Bool) -> Void)?
+
+	public var connected: Bool {
+		return socket?.readyState == .Some(.Open)
+	}
 
 	private var heartBeatTimer: NSTimer?
 	private var reconnectTimer: NSTimer?


	@objc public func webSocketEnd(code: Int, reason: String, wasClean: Bool, error: NSError?) {
		// close and error handled here.
//		onSocketError?(code: code, reason: reason, wasClean: wasClean, error: error)
	}
}

	private var lastParams: [NSURLQueryItem]?
	private let queue = NSOperationQueue()

	public init(url: NSURL, heartbeatInterval: NSTimeInterval = 0.0, reconnectInterval: NSTimeInterval = 5.0) {
		self.url = url
		self.heartbeatInterval = heartbeatInterval
		self.reconnectInterval = reconnectInterval

		queue.suspended = true
	}
