File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -43,11 +43,11 @@ class SocketPacket {
43
43
case BINARY_EVENT = 5
44
44
case BINARY_ACK = 6
45
45
46
- init ( str: String ) {
47
- if let int = str. toInt ( ) {
48
- self = PacketType ( rawValue : int ) !
46
+ init ? ( str: String ) {
47
+ if let int = str. toInt ( ) , let raw = PacketType ( rawValue : int ) {
48
+ self = raw
49
49
} else {
50
- self = PacketType ( rawValue : 4 ) !
50
+ return nil
51
51
}
52
52
}
53
53
}
Original file line number Diff line number Diff line change @@ -185,7 +185,14 @@ class SocketParser {
185
185
return nsp == " " && socket. nsp != " / "
186
186
}
187
187
188
- let p = parseString ( stringMessage) as SocketPacket !
188
+ let p : SocketPacket
189
+
190
+ if let pack = parseString ( stringMessage) {
191
+ p = pack
192
+ } else {
193
+ socket. didError ( " Error parsing packet " )
194
+ return
195
+ }
189
196
190
197
if p. type == SocketPacket . PacketType. EVENT {
191
198
if checkNSP ( p. nsp) {
You can’t perform that action at this time.
0 commit comments