OLD | NEW |
(Empty) | |
| 1 |
| 2 class _WebSocketImpl extends _EventTargetImpl implements WebSocket { |
| 3 _WebSocketImpl._wrap(ptr) : super._wrap(ptr); |
| 4 |
| 5 String get URL() => _wrap(_ptr.URL); |
| 6 |
| 7 String get binaryType() => _wrap(_ptr.binaryType); |
| 8 |
| 9 void set binaryType(String value) { _ptr.binaryType = _unwrap(value); } |
| 10 |
| 11 int get bufferedAmount() => _wrap(_ptr.bufferedAmount); |
| 12 |
| 13 String get extensions() => _wrap(_ptr.extensions); |
| 14 |
| 15 String get protocol() => _wrap(_ptr.protocol); |
| 16 |
| 17 int get readyState() => _wrap(_ptr.readyState); |
| 18 |
| 19 String get url() => _wrap(_ptr.url); |
| 20 |
| 21 _WebSocketEventsImpl get on() { |
| 22 if (_on == null) _on = new _WebSocketEventsImpl(this); |
| 23 return _on; |
| 24 } |
| 25 |
| 26 void _addEventListener(String type, EventListener listener, [bool useCapture =
null]) { |
| 27 if (useCapture === null) { |
| 28 _ptr.addEventListener(_unwrap(type), _unwrap(listener)); |
| 29 return; |
| 30 } else { |
| 31 _ptr.addEventListener(_unwrap(type), _unwrap(listener), _unwrap(useCapture
)); |
| 32 return; |
| 33 } |
| 34 } |
| 35 |
| 36 void close([int code = null, String reason = null]) { |
| 37 if (code === null) { |
| 38 if (reason === null) { |
| 39 _ptr.close(); |
| 40 return; |
| 41 } |
| 42 } else { |
| 43 if (reason === null) { |
| 44 _ptr.close(_unwrap(code)); |
| 45 return; |
| 46 } else { |
| 47 _ptr.close(_unwrap(code), _unwrap(reason)); |
| 48 return; |
| 49 } |
| 50 } |
| 51 throw "Incorrect number or type of arguments"; |
| 52 } |
| 53 |
| 54 bool _dispatchEvent(Event evt) { |
| 55 return _wrap(_ptr.dispatchEvent(_unwrap(evt))); |
| 56 } |
| 57 |
| 58 void _removeEventListener(String type, EventListener listener, [bool useCaptur
e = null]) { |
| 59 if (useCapture === null) { |
| 60 _ptr.removeEventListener(_unwrap(type), _unwrap(listener)); |
| 61 return; |
| 62 } else { |
| 63 _ptr.removeEventListener(_unwrap(type), _unwrap(listener), _unwrap(useCapt
ure)); |
| 64 return; |
| 65 } |
| 66 } |
| 67 |
| 68 bool send(String data) { |
| 69 return _wrap(_ptr.send(_unwrap(data))); |
| 70 } |
| 71 } |
| 72 |
| 73 class _WebSocketEventsImpl extends _EventsImpl implements WebSocketEvents { |
| 74 _WebSocketEventsImpl(_ptr) : super(_ptr); |
| 75 |
| 76 EventListenerList get close() => _get('close'); |
| 77 |
| 78 EventListenerList get error() => _get('error'); |
| 79 |
| 80 EventListenerList get message() => _get('message'); |
| 81 |
| 82 EventListenerList get open() => _get('open'); |
| 83 } |
OLD | NEW |