Skip to content

Commit 7ff1d32

Browse files
committed
Fix #203
1 parent 18a227e commit 7ff1d32

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

SocketIOClientSwift/SocketEngine.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,15 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
530530
private func parseEngineMessage(var message: String, fromPolling: Bool) {
531531
Logger.log("Got message: %@", type: logType, args: message)
532532

533-
if fromPolling {
534-
fixDoubleUTF8(&message)
535-
}
536-
537533
let type = PacketType(str: (message["^(\\d)"].groups()?[1]) ?? "") ?? {
538534
self.checkIfMessageIsBase64Binary(message)
539535
return .Noop
540536
}()
537+
538+
539+
if fromPolling && type != .Noop {
540+
fixDoubleUTF8(&message)
541+
}
541542

542543
switch type {
543544
case PacketType.Message:

SocketIOClientSwift/SocketFixUTF8.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import Foundation
2727

2828
func fixDoubleUTF8(inout name: String) {
29+
print(name)
2930
let utf8 = name.dataUsingEncoding(NSISOLatin1StringEncoding)!
3031
let latin1 = NSString(data: utf8, encoding: NSUTF8StringEncoding)!
3132
name = latin1 as String

SocketIOClientSwift/SocketPacket.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ struct SocketPacket {
116116

117117
message += jsonString! as String + ","
118118
} catch {
119-
Logger.error("Error creating JSON object in SocketPacket.completeMessage", type: SocketPacket.logType)
119+
Logger.error("Error creating JSON object in SocketPacket.completeMessage", type: SocketPacket.logType)
120120
}
121121
} else if var str = arg as? String {
122122
str = str["\n"] ~= "\\\\n"

0 commit comments

Comments
 (0)