浏览代码

Merge pull request #147 from mbarnach/Hashable_Equatable_WebSocketSession

Make web socket hashable and comparable.
Damian Kołakowski 10 年之前
父节点
当前提交
623e152dcd
共有 1 个文件被更改,包括 11 次插入1 次删除
  1. 11 1
      Sources/WebSockets.swift

+ 11 - 1
Sources/WebSockets.swift

@@ -46,7 +46,7 @@ public func websocket(
     }
 }
 
-public class WebSocketSession {
+public class WebSocketSession: Hashable, Equatable  {
     
     public enum Error: ErrorType { case UnknownOpCode(String), UnMaskedFrame }
     public enum OpCode { case Continue, Close, Ping, Pong, Text, Binary }
@@ -169,4 +169,14 @@ public class WebSocketSession {
         }
         return frm
     }
+    
+    public var hashValue: Int {
+        get {
+            return socket.hashValue
+        }
+    }
+}
+
+public func ==(webSocketSession1: WebSocketSession, webSocketSession2: WebSocketSession) -> Bool {
+    return webSocketSession1.socket == webSocketSession2.socket
 }