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
e823ecef
Unverified
Commit
e823ecef
authored
4 years ago
by
scratchyone
Browse files
Options
Downloads
Patches
Plain Diff
Improve compilation errors when compiling to incompatible targets
parent
4d1f2424
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Cargo.toml
+1
-1
1 addition, 1 deletion
Cargo.toml
src/lib.rs
+5
-0
5 additions, 0 deletions
src/lib.rs
with
6 additions
and
1 deletion
Cargo.toml
+
1
−
1
View file @
e823ecef
[package]
name
=
"wasm-sockets"
version
=
"0.
1
.0"
version
=
"0.
2
.0"
authors
=
[
"scratchyone <scratchywon@gmail.com>"
]
edition
=
"2018"
license
=
"MIT"
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
5
−
0
View file @
e823ecef
...
...
@@ -96,6 +96,9 @@ use wasm_bindgen::prelude::*;
use
wasm_bindgen
::
JsCast
;
use
web_sys
::{
ErrorEvent
,
MessageEvent
,
WebSocket
};
#[cfg(not(target_arch
=
"wasm32"
))]
compile_error!
(
"wasm-sockets can only compile to WASM targets"
);
#[derive(Debug,
Clone,
PartialEq)]
pub
enum
ConnectionStatus
{
/// Connecting to a server
...
...
@@ -116,6 +119,7 @@ pub enum Message {
/// A binary message
Binary
(
Vec
<
u8
>
),
}
#[cfg(target_arch
=
"wasm32"
)]
pub
struct
PollingClient
{
/// The URL this client is connected to
pub
url
:
String
,
...
...
@@ -125,6 +129,7 @@ pub struct PollingClient {
pub
status
:
Rc
<
RefCell
<
ConnectionStatus
>>
,
data
:
Rc
<
RefCell
<
Vec
<
Message
>>>
,
}
#[cfg(target_arch
=
"wasm32"
)]
// TODO: Replace unwraps and JsValue with custom error type
impl
PollingClient
{
/// Create a new PollingClient and connect to a WebSocket URL
...
...
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