OutgoingMessage.fromBinary constructor
OutgoingMessage.fromBinary(
- Uint8List data
Implementation
factory OutgoingMessage.fromBinary(Uint8List data) {
var bdata = new ByteData.view(data.buffer);
int type = bdata.getUint8(0);
int w = 2;
int s = 0;
String nick = '';
s = bdata.getUint16(w);
w += 2;
if (s != 0) {
nick = utf8.decode(data.sublist(w, w + s));
w += s;
}
String avatar = '';
s = bdata.getUint16(w);
w += 2;
if (s != 0) {
avatar = utf8.decode(data.sublist(w, w + s));
w += s;
}
String text = '';
s = bdata.getUint16(w);
w += 2;
if (s != 0) {
text = utf8.decode(data.sublist(w, w + s));
w += s;
}
String sl = '';
s = bdata.getUint16(w);
w += 2;
if (s != 0) {
sl = utf8.decode(data.sublist(w, w + s));
w += s;
}
String pp = '';
s = bdata.getUint16(w);
w += 2;
if (s != 0) {
pp = utf8.decode(data.sublist(w, w + s));
w += s;
}
int tsta = bdata.getUint64(w);
w += 8;
Uint8List at = Uint8List(0);
s = bdata.getUint64(w);
w += 8;
if (s != 0) {
at = data.sublist(w, w + s);
w += s;
}
String cid = '';
s = bdata.getUint16(w);
w += 2;
if (s != 0) {
cid = utf8.decode(data.sublist(w, w + s));
w += s;
}
String atty = '';
if (w < bdata.lengthInBytes - 8) {
s = bdata.getUint16(w);
w += 2;
if (s != 0) {
atty = utf8.decode(data.sublist(w, w + s));
w += s;
}
}
int xxHash = 0;
if (w < bdata.lengthInBytes - 8) {
xxHash = bdata.getUint64(w);
w += 8;
}
return OutgoingMessage(
type, nick, avatar, text, sl, pp, tsta, at, cid, atty, xxHash);
}