Skip to content

Commit b2e612a

Browse files
author
闫逍旭
committed
error message add data, push message content string->bytes
1 parent a1723ea commit b2e612a

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

mpush_client/ClientListener.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protocol ClientListener {
1616

1717
func onHandshakeOk(client: Client, heartbeat: Int);
1818

19-
func onReceivePush(client: Client, content: String);
19+
func onReceivePush(client: Client, content: NSData);
2020

2121
func onKickUser(deviceId: String, userId: String);
2222
}

mpush_client/DefaultClientListener.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ final class DefaultClientListener: ClientListener {
3939
}
4040
}
4141

42-
func onReceivePush(client: Client, content: String) {
42+
func onReceivePush(client: Client, content: NSData) {
4343
if let listener = self.listener {
4444
dispatch_async(dispatch_queue, {listener.onReceivePush(client, content: content)})
4545
}

mpush_client/ErrorMessage.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
import Foundation
1010

1111
final class ErrorMessage: ByteBufMessage, CustomDebugStringConvertible {
12-
var cmd:Int8 = 0;
13-
var code:Int8 = 0;
14-
var reason:String?;
12+
var cmd: Int8 = 0;
13+
var code: Int8 = 0;
14+
var reason: String?;
15+
var data: String?;
1516

1617
override func decode(body: RFIReader) {
1718
cmd = body.readByte();
1819
code = body.readByte();
1920
reason = body.readString();
21+
data = body.readString();
2022
}
2123

2224

mpush_client/PacketDecoder.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ final class PacketDecoder {
2525
return Packet.HB_PACKET;
2626
}
2727
buffer.reset();
28-
2928
}
3029
return nil;
3130
}
@@ -54,7 +53,7 @@ final class PacketDecoder {
5453
let data = buffer.readBytes(bodyLength)
5554
body = NSData(bytes: data, length: data.count);
5655
}
57-
return Packet(cmd: command,cc: cc,flags: flags,sessionId: sessionId,lrc:lrc,body:body);
56+
return Packet(cmd: command, cc: cc, flags: flags, sessionId: sessionId, lrc: lrc, body: body);
5857
}
5958

6059
}

mpush_client/PushMessage.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
import Foundation
1010

1111
final class PushMessage: BaseMessage, CustomDebugStringConvertible {
12-
var content:String!;
12+
var content:NSData!;
1313

1414
override func decode(body:NSData) {
15-
content = String(data: body, encoding:NSUTF8StringEncoding)
15+
content = body;
1616
}
1717

1818
var debugDescription: String {
19-
return "PushMessage={content:\(content)}"
19+
return "PushMessage={content:\(content.length)}"
2020
}
2121
}

mpush_clientTests/mpush_clientTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class mpush_clientTests: XCTestCase {
6060
}
6161
}
6262

63-
func onReceivePush(client: Client, content: String){}
63+
func onReceivePush(client: Client, content: NSData){}
6464

6565
func onKickUser(deviceId: String, userId: String){}
6666
}

0 commit comments

Comments
 (0)