Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Wasm Sockets
Manage
Activity
Members
Labels
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Wasm Sockets
Commits
07f7f5c0
Unverified
Commit
07f7f5c0
authored
4 years ago
by
scratchyone
Browse files
Options
Downloads
Patches
Plain Diff
Fix panic on error
parent
7cfe5d00
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib.rs
+5
-5
5 additions, 5 deletions
src/lib.rs
with
5 additions
and
5 deletions
src/lib.rs
+
5
−
5
View file @
07f7f5c0
...
@@ -86,7 +86,7 @@
...
@@ -86,7 +86,7 @@
//! ```
//! ```
#[cfg(test)]
#[cfg(test)]
mod
tests
;
mod
tests
;
use
log
::
trace
;
use
log
::
{
error
,
trace
}
;
use
std
::
cell
::
RefCell
;
use
std
::
cell
::
RefCell
;
use
std
::
rc
::
Rc
;
use
std
::
rc
::
Rc
;
use
thiserror
::
Error
;
use
thiserror
::
Error
;
...
@@ -103,7 +103,7 @@ pub enum ConnectionStatus {
...
@@ -103,7 +103,7 @@ pub enum ConnectionStatus {
/// Connected to a server
/// Connected to a server
Connected
,
Connected
,
/// Disconnected from a server due to an error
/// Disconnected from a server due to an error
Error
(
ErrorEvent
)
,
Error
,
/// Disconnected from a server without an error
/// Disconnected from a server without an error
Disconnected
,
Disconnected
,
}
}
...
@@ -148,7 +148,7 @@ impl PollingClient {
...
@@ -148,7 +148,7 @@ impl PollingClient {
let
status_ref
=
status
.clone
();
let
status_ref
=
status
.clone
();
client
.set_on_error
(
Some
(
Box
::
new
(
move
|
e
|
{
client
.set_on_error
(
Some
(
Box
::
new
(
move
|
e
|
{
*
status_ref
.borrow_mut
()
=
ConnectionStatus
::
Error
(
e
)
;
*
status_ref
.borrow_mut
()
=
ConnectionStatus
::
Error
;
})));
})));
let
status_ref
=
status
.clone
();
let
status_ref
=
status
.clone
();
...
@@ -238,7 +238,7 @@ impl EventClient {
...
@@ -238,7 +238,7 @@ impl EventClient {
let
ws
:
web_sys
::
WebSocket
=
match
WebSocket
::
new
(
url
)
{
let
ws
:
web_sys
::
WebSocket
=
match
WebSocket
::
new
(
url
)
{
Ok
(
ws
)
=>
ws
,
Ok
(
ws
)
=>
ws
,
Err
(
e
)
=>
Err
(
WebSocketError
::
ConnectionCreationError
(
Err
(
e
)
=>
Err
(
WebSocketError
::
ConnectionCreationError
(
e
.as_string
()
.unwrap
(),
"Failed to connect"
.into
(),
))
?
,
))
?
,
};
};
// For small binary messages, like CBOR, Arraybuffer is more efficient than Blob handling
// For small binary messages, like CBOR, Arraybuffer is more efficient than Blob handling
...
@@ -252,7 +252,7 @@ impl EventClient {
...
@@ -252,7 +252,7 @@ impl EventClient {
let
on_error_ref
=
on_error
.clone
();
let
on_error_ref
=
on_error
.clone
();
let
onerror_callback
=
Closure
::
wrap
(
Box
::
new
(
move
|
e
:
ErrorEvent
|
{
let
onerror_callback
=
Closure
::
wrap
(
Box
::
new
(
move
|
e
:
ErrorEvent
|
{
*
ref_status
.borrow_mut
()
=
ConnectionStatus
::
Error
(
e
.clone
())
;
*
ref_status
.borrow_mut
()
=
ConnectionStatus
::
Error
;
if
let
Some
(
f
)
=
&*
on_error_ref
.borrow
()
{
if
let
Some
(
f
)
=
&*
on_error_ref
.borrow
()
{
f
.as_ref
()(
e
);
f
.as_ref
()(
e
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment