Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using websockets in javascript library #837

Closed
Bezdekm opened this issue Sep 22, 2016 · 3 comments
Closed

Using websockets in javascript library #837

Bezdekm opened this issue Sep 22, 2016 · 3 comments

Comments

@Bezdekm
Copy link

Bezdekm commented Sep 22, 2016

Hello,
I have one question. I have one main server written in Node.JS. And I have one javascript library that is running on the client by inserting <script src="xxx.js"></script> tag. The nodeJS server is running on stable URL and the client's library can be anywhere.

Is there any possibility to hold connection between the server and client? A mean import ws into client's pure javascript library which will connect to the server (nodeJS application)?

Thanks!

@JoshuaWise
Copy link
Member

To use WebSockets in a browser, you have to use the native WebSocket global object.

You can read about it here: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket

@Bezdekm
Copy link
Author

Bezdekm commented Sep 22, 2016

Ok, thanks. So I can use native WebSocket object in the client library, on the server I will use this WS package and together it will works well?

@JoshuaWise
Copy link
Member

That's exactly right!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants