|
|
|
@ -41,6 +41,9 @@ class SocketClient {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
authRequest(String token) { |
|
|
|
|
if (!checkSocket()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
final authReq = AuthReq() |
|
|
|
|
..uid = 1 |
|
|
|
|
..token = '123456'; |
|
|
|
@ -51,10 +54,21 @@ class SocketClient {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sendMessage(var to, String content) { |
|
|
|
|
if (!checkSocket()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
Uint8List data = utf8.encode(content); |
|
|
|
|
MsgData msgData = MsgData(to: to,from: 2,type: MsgType.SINGLE_TEXT,data: data); |
|
|
|
|
final proto2 = Proto(5,1,msgData.writeToBuffer()); |
|
|
|
|
_socket.add(proto2.toBytes()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
checkSocket() { |
|
|
|
|
if (_socket == null) { |
|
|
|
|
connect(); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |