Commit Graph

32 Commits

Author SHA1 Message Date
Pierre Ossman ae9b042df1 Change rQslice() to rQpeekBytes()
We don't need any full slice functionality, so let's change this to
better march rQpeek8() and rQshiftBytes().
2023-06-04 19:00:33 +02:00
Ryo Ota 2a675b3394
fix typo 2023-04-30 02:04:00 +09:00
Pierre Ossman de9fc9508c Don't fake open events in Websock
We don't know if the caller is prepared to receive those events right
now as normally they would get them on a fresh new stack later. We also
can't delay delivery since then we might deliver the event after any
pending "message" events.

Better to push the problem one layer up to the caller, which now needs
to be more aware of the state of the WebSocket object it is trying to
use.
2021-04-18 14:26:30 +02:00
Pierre Ossman b7b7e4e26b Provide readyState for Websock objects
It mainly reports the state of the underlying object in consistent
manner.
2021-04-18 14:26:05 +02:00
Tim Stableford 44d384b99c Added support for RTCDataChannel
This work is originally by Ryan Castner <castner.rr@gmail.com> and
submitted as a PR here https://github.com/novnc/noVNC/pull/1362

Architecturally it is much the same except it doesn't rename a lot
of variables to make this more reviewable. It also avoids unrelated
changes such as replacing .onclose with an event listener, which
caused numerous test failures.

It also adds in ppoffice's fix to initialise the buffers.

Like the original author I don't have enough time available to
refactor this project to the new style event listeners.

Review cleanup for RTCDataChannel support (see below)

* More descriptive error when url or channel not set.
* Moved websocket property check to WebSock.
  This had unintended consequences in the tests that required some
  fixup. Mostly due to some tests not always passing FakeWebsocket.
  FakeWebsocket also needs to set the listeners to null to be compatible
  with what is in thw browser and expected by the property check code.
  The property check code now also takes into account class prototypes
  for test compatibility.
* Removed unreachable code.
* Reverted comment.
* Cleanup raw channel reference in rfb on websock close.
* Use readyState to check whether a socket is open rather than assuming.
* Updated RFB constructor documentation

Removed an unused boolean passed to attach
2021-03-04 18:55:06 +00:00
Pierre Ossman 5b5b747494 Remove many small, obsolete, old browser hacks
These are for browsers no longer supported anyway.
2020-12-07 10:10:53 +01:00
Samuel Mannehed ea858bfa27 Standardize on camelCase in Websock 2020-05-31 23:21:35 +02:00
Samuel Mannehed 412d93060d Update copyright to 2019 for modified files 2019-09-30 15:35:33 +02:00
Samuel Mannehed e8614e20ef Code comments for how the receieve queue works 2019-09-25 21:04:46 +02:00
Samuel Mannehed c90d53565a Clarify why we ENABLE_COPYWITHIN is false 2019-09-25 21:03:37 +02:00
Jesper Alf Dam 08567b08ac When compacting the receive buffer don't copy unused buffer space
When compacting the receive buffer, we should only copy the bytes
between _rQi and _rQlen (the index of the first unread byte, and the
next write position).

Previously, we copied everything for _rQi up untill the end of the
buffer.
2019-08-16 19:34:09 +02:00
Jesper Alf Dam 7d755d10dc Don't compact the receive buffer unless we've actually run out of space
Previously, we would compact the buffer (moving unread data to the
start of the buffer) as follows:

- after processing a message, if there are zero unread bytes, just reset
  the indices for first and last unread byte to zero
- else, if at least 1/8th of the buffer is used, copy remaining data to the beginning of the buffer

The second option is never actually necessary, as before inserting new data
into the array, we already check if there's enough free space, and
compact the buffer first if necessary. So we've been doing a lot of
copies that weren't actually needed. Let's not do that any more.
2019-08-16 19:34:09 +02:00
Juanjo Diaz 879e33ab64 Extract rQshift to common function 2018-12-08 17:32:00 +02:00
Juanjo Diaz 8a189a6291 Add getters/setter to websock 2018-12-08 17:31:20 +02:00
Solly Ross 84586c0f17 Change copyright header (#1138)
* Change copyright header

This updates the copyright header to say "The noVNC Authors".  People
who previously had copyright listings are now under the AUTHORS file.
2018-10-09 12:15:35 +02:00
Juanjo Diaz 651c23ece3 Use fat arrow functions `const foo = () => { ... };` for callbacks
and any other function that is passed around and it's not a top level function
2018-07-12 19:06:57 +02:00
Juanjo Diaz 0e4808bf6f Use ES6 classes
Always use the shorthand notation if the function is a method of an object or class `{ foo() { ... } }` or `class bar { foo() { ... } }`
unless it's a callback in which case you a fat arrow function should be used `{ cb: () => { ... } }`
2018-07-12 19:06:57 +02:00
Samuel Mannehed f90c2a6d4b Avoid TypedArray.slice() because of IE11 2018-06-15 12:00:43 +02:00
Samuel Mannehed d9814c06bf Use string assignment operator instead of concat()
The assignment operator is a lot faster.
2018-06-15 11:59:28 +02:00
Samuel Mannehed 4318c8cafd Use the correct slicing for rQshiftStr
This didn't result in any error however since slice() handles such
mistakes gracefully.
2018-06-15 11:56:56 +02:00
Samuel Mannehed db9daa98a5 Avoid big strings on the stack
Previous code resulted in RangeErrors by potentially creating big
strings.

Fixes issue #1065
2018-06-14 16:59:52 +02:00
Samuel Mannehed 362bd5e3a2 Call rQshiftBytes to avoid code duplication 2018-06-14 16:51:29 +02:00
Samuel Mannehed e87b645b56 Remove typedArrayToString
We don't use PhantomJS anymore
2018-06-14 16:43:48 +02:00
Juanjo Diaz 2b5f94fa6a Prefer const/let over var 2018-05-24 00:27:09 +03:00
Juanjo Diaz 8727f598c2 Add eslint and fix reported issues 2018-05-24 00:25:44 +03:00
Juanjo Diaz 9e1bd410aa Remove jshint comments 2018-01-31 07:38:29 -08:00
Pierre Ossman 7f39868158 Remove noisy websock debug logging
It generates too many log lines that it drowns out everything else.
2017-11-24 13:10:35 +01:00
Pierre Ossman 1678bf860f Stop hiding exceptions in WebSock class
Let them application decide how to deal with such things and do not
enforce this particular model, which easily hides bugs.
2017-09-07 17:18:25 +02:00
Solly Ross 6d6f0db0da Refactor ES6 module structure/split up Util
This commit restructures many of the ES6 modules, splitting them
up to actual export multiple functions instead of a single object.

It also splits up Util into multiple sub-modules, to make it easier
to maintain.

Finally, localisation is renamed to localization.
2017-03-21 17:39:05 -04:00
Solly Ross 3ae0bb0968 Uncomment ES6 module syntax
This removes the special comment part of the ES6 module syntax,
opting to enable ES6 module syntax by default.

It also appends `.js` to all import paths to better support in-browser
loading.
2017-02-26 16:30:37 -05:00
Pierre Ossman d2467189f5 Don't delay WebSocket flushing
The native WebSocket is in a much better position to do queue
management than us. We also failed to check the return value and
set up a timer, causing stalls.

This gets us in sync with websockify as of 40238b00.
2017-02-03 17:12:41 +01:00
Solly Ross ae510306b5 Enable noVNC to become Browserifiable
This commit restructures noVNC, splitting it into the core directory
and the app directory, with the former containing core noVNC parts,
and the latter containing parts specific to the application.
2016-09-16 15:49:51 -04:00