Skip to content

Commit

Permalink
error message add data, push message content string->bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
闫逍旭 committed Aug 19, 2016
1 parent a1723ea commit b2e612a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mpush_client/ClientListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protocol ClientListener {

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

func onReceivePush(client: Client, content: String);
func onReceivePush(client: Client, content: NSData);

func onKickUser(deviceId: String, userId: String);
}
2 changes: 1 addition & 1 deletion mpush_client/DefaultClientListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class DefaultClientListener: ClientListener {
}
}

func onReceivePush(client: Client, content: String) {
func onReceivePush(client: Client, content: NSData) {
if let listener = self.listener {
dispatch_async(dispatch_queue, {listener.onReceivePush(client, content: content)})
}
Expand Down
8 changes: 5 additions & 3 deletions mpush_client/ErrorMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
import Foundation

final class ErrorMessage: ByteBufMessage, CustomDebugStringConvertible {
var cmd:Int8 = 0;
var code:Int8 = 0;
var reason:String?;
var cmd: Int8 = 0;
var code: Int8 = 0;
var reason: String?;
var data: String?;

override func decode(body: RFIReader) {
cmd = body.readByte();
code = body.readByte();
reason = body.readString();
data = body.readString();
}


Expand Down
3 changes: 1 addition & 2 deletions mpush_client/PacketDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ final class PacketDecoder {
return Packet.HB_PACKET;
}
buffer.reset();

}
return nil;
}
Expand Down Expand Up @@ -54,7 +53,7 @@ final class PacketDecoder {
let data = buffer.readBytes(bodyLength)
body = NSData(bytes: data, length: data.count);
}
return Packet(cmd: command,cc: cc,flags: flags,sessionId: sessionId,lrc:lrc,body:body);
return Packet(cmd: command, cc: cc, flags: flags, sessionId: sessionId, lrc: lrc, body: body);
}

}
6 changes: 3 additions & 3 deletions mpush_client/PushMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import Foundation

final class PushMessage: BaseMessage, CustomDebugStringConvertible {
var content:String!;
var content:NSData!;

override func decode(body:NSData) {
content = String(data: body, encoding:NSUTF8StringEncoding)
content = body;
}

var debugDescription: String {
return "PushMessage={content:\(content)}"
return "PushMessage={content:\(content.length)}"
}
}
2 changes: 1 addition & 1 deletion mpush_clientTests/mpush_clientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class mpush_clientTests: XCTestCase {
}
}

func onReceivePush(client: Client, content: String){}
func onReceivePush(client: Client, content: NSData){}

func onKickUser(deviceId: String, userId: String){}
}
Expand Down

0 comments on commit b2e612a

Please sign in to comment.