Comments (2)
The above scope we discussed is called browsing context according to W3C's HTML5 spec and it seems that window.name
is the only storage sharing its life cycle with browsing context. Since it is just the name of the window, our use case may be a misuse and not reliable but I couldn't find a better alternative or a unobtrusive solution.
For this feature, we need a new option, name?: string
. name
is an identifier of a socket within document and used to identify a specific socket in each document within browsing context. A user should define it explicitly as it can't have default value.
// A socket whose name is 'main' after page navigation will continue this socket's life cycle
cettia.open("/cettia", {name: "main"});
Actually, uri
might be suitable as the default value of name
option but if two sockets sharing the same uri
exist in the same page or uri
is generated programmatically e.g. cettia.open("/cettia?time=" + Date.now())
, it won't work.
Now we need how to use window.name
to get/set data indicating that which name corresponds to which socket.
from cettia-javascript-client.
Because a way depending on window.name
itself is obstructive unlike cookie or session storage, there is no way to avoid conflicting with existing libraries using window.name
. That's why it doesn't matter even if we monopolizes window.name
. Of course user should be aware of that.
As for how to use window.name
, window.name
will be a JSON representation of an object whose key is name
option and value is socket id
. That's all.
from cettia-javascript-client.
Related Issues (20)
- Drop support for IE 6-8 according to the death of jQuery Compat 3.0 HOT 2
- Add README.md
- Support bundler such as Webpack, Browserify and Rollup HOT 4
- Prefix query params representing protocol header HOT 2
- Release needed for webpack compatible version HOT 2
- Support Node 6 and 7
- Update dependencies HOT 4
- Tests fail with ws 1.1+ HOT 3
- Fix a typo in webpack configuration HOT 1
- 1.0.0-RC1 HOT 1
- Add the version protocol header
- Reconnection doesn't work HOT 1
- React Native support HOT 1
- If a connection is recovered by reconnection, multiple connections are opened for some reason
- Update dependencies HOT 2
- Run tests on Node 8+
- Rewrite README.md
- Decode Base64 string to ArrayBuffer correctly
- ArrayBuffer not sent as binary message HOT 1
- Binary event HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cettia-javascript-client.