Skip to content

Commit

Permalink
fix type error at runtime.
Browse files Browse the repository at this point in the history
  • Loading branch information
jumperchen committed Nov 20, 2018
1 parent fb52207 commit e3bf03d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Client {
connect(name, [query]) {
_logger.fine('connecting to namespace $name');
if (!this.server.nsps.containsKey(name)) {
this.packet({'type': ERROR, 'nsp': name, 'data': 'Invalid namespace'});
this.packet(<dynamic, dynamic>{'type': ERROR, 'nsp': name, 'data': 'Invalid namespace'});
return;
}
var nsp = this.server.of(name);
Expand Down Expand Up @@ -174,8 +174,8 @@ class Client {
// try/catch is needed for protocol violations (GH-1880)
try {
this.decoder.add(data);
} catch (e) {
_logger.severe(e, (e as Error).stackTrace);
} catch (e, st) {
_logger.severe(e, st);
this.onerror(e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/engine/parser/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class PacketParser {
continue;
}

if (length.isEmpty || (length != '${(n = num.parse(length))}')) {
if (length.isEmpty || (length != '${(n = num.tryParse(length))}')) {
// parser error - ignoring payload
return callback(ERROR, 0, 1);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/engine/socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Socket extends EventEmitter {
* @api private
*/

onPacket(Map packet) {
onPacket(packet) {
if ('open' == this.readyState) {
// export packet event
_logger.fine('packet');
Expand Down
2 changes: 1 addition & 1 deletion lib/src/engine/transport/polling_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class PollingTransport extends Transport {
var contentType =
isString ? 'text/plain; charset=UTF-8' : 'application/octet-stream';

var headers = {'Content-Type': contentType};
final Map headers = {'Content-Type': contentType};

var respond = (data) {
headers[HttpHeaders.contentLengthHeader] =
Expand Down
6 changes: 3 additions & 3 deletions lib/src/parser/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class Decoder extends EventEmitter {
buf += str[i];
if (i == endLen) break;
}
if (buf != '${num.parse(buf)}' || str[i] != '-') {
if (buf != '${num.tryParse(buf) ?? -1}' || str[i] != '-') {
throw new ArgumentError('Illegal attachments');
}
p['attachments'] = num.parse(buf);
Expand All @@ -222,11 +222,11 @@ class Decoder extends EventEmitter {

// look up id
var next = i < endLen - 1 ? str[i + 1] : null;
if (next?.isNotEmpty == true && '${num.parse(next)}' == next) {
if (next?.isNotEmpty == true && '${num.tryParse(next)}' == next) {
p['id'] = '';
while (++i > 0) {
var c = str[i];
if (null == c || '${num.parse(c)}' != c) {
if (null == c || '${num.tryParse(c)}' != c) {
--i;
break;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/src/socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class Socket extends EventEmitter {
// debug('socket connected - writing packet');
this.nsp.connected[this.id] = this;
this.join(this.id);
this.packet({'type': CONNECT});
this.packet(<dynamic, dynamic>{'type': CONNECT});
}

/**
Expand Down Expand Up @@ -366,7 +366,7 @@ class Socket extends EventEmitter {
// debug('sending ack %j', args);

var type = /*hasBin(args) ? parser.BINARY_ACK : parser.*/ ACK;
packet({
packet(<dynamic, dynamic>{
'id': id,
'type': type,
'data': [_]
Expand Down Expand Up @@ -441,7 +441,7 @@ class Socket extends EventEmitter {
* @api private
*/
error(err) {
this.packet({'type': ERROR, 'data': err});
this.packet(<dynamic, dynamic>{'type': ERROR, 'data': err});
}

/**
Expand All @@ -457,7 +457,7 @@ class Socket extends EventEmitter {
if (close == true) {
this.client.disconnect();
} else {
this.packet({'type': DISCONNECT});
this.packet(<dynamic, dynamic>{'type': DISCONNECT});
this.onclose('server namespace disconnect');
}
return this;
Expand Down

0 comments on commit e3bf03d

Please sign in to comment.