Peer to Peer Connection in Windows Store App (HTML/JS) - javascript

I'd like to know if anyone has managed to set up a peer-to-peer app for the Windows Store using HTML5 and JavaScript. Basically I want app client A to be able to connect and send data to app client B via a TCP or UDP socket (the problem I'm facing seems to be irrelevant to the socket type).
My main problem is that I am unsure how to obtain a suitable IP/port which the other client would be able to connect to. It seems like there would be issues with router firewalls and whatnot, but MS claims that peer-to-peer is possible.
Any tips would be greatly appreciated, thanks.
Edit: I cannot use a third party service for communicating the data, because I want my app to be able to connect with other applications besides the one I'm writing. So something standard like TCP sockets is necessary.

Take a look at TideSDK for the desktop app development with web technology.
I don't know is TideSDK provide an API to access TCP or UDP communication, may be you could try read the docs. IMO best is you need to create a server to handle 1:1 connection between clients.
If you dont want to get mess with the server, you should get to know PubNub and Pusher

Related

How to detect a server in the network using JS?

Basically, I want to make a peer to peer architecture, using JavaScript (Ionic).
Since, JS cannot create sockets/etc; a NodeJS server has to be introduced between the clients; acting as the Socket.IO server between the clients.
The problem with this, is that the Socket.IO (NodeJS) server would need to be automatically found within the local network -- by the clients (instead of hardcoded/configured).
Are there any ways to implement such a thing; or alternatives to this architecture?
Thanks for the help!
Are there any ways to implement such a thing; or alternatives to this architecture?
Currently your architecture is using a browser app plus a Node app that users need to have on their network just to create TCP connections.
What you can do instead is create an Electron app that combines a Node app, a browser app, and a browser itself. See:
https://electron.atom.io/
With Electron you can write your frontend code almost the same way as for the regular browser, but you can use the entire Node API including the TCP sockets so there will be no need to create a separate Node app and to search for that app in the network. This can greatly simplify your architecture.
Note: this is not an answer to the first part of the question: "How to detect a server in the network using JS?" but to the second part of the question: "Are there any ways to implement such a thing; or alternatives to this architecture?" Detecting the servers on the local network with client-side JavaScript will not be easy - and in fact it shouldn't be even possible because websites being able to scan your LAN for active services would be a serious problem for privacy and security.

Socket.io and Node.Js multiple servers

I'm new to Web Sockets in general, but get the main concept.
I am trying to build a simple multiplayer game and would like to have a server selection where I can run sockets on multiple IPs and it will connect the client through that, to mitigate connections in order to improve performance, this is hypothetical in the case of there being thousands of players at once, but would like some insight into how this would work and if there are any resources I can use to integrate this before hand, in order to prevent extra work at a later date. Is this at all possible, as I understand it Node.Js runs on a server and uses the Socket.io dependencies to create sockets within that, so I can't think of a possible solution to route it through another server unless I had multiple sites running it separately.
The first question I have is this:
Are you hosting on AWS or in a local datacenter?
The reason I ask is because SOCKET.io requires sticky sessions to work properly across multiple servers. Due to the fact that SOCKET.io will attempt to upgrade each connection, and because that upgrade request must reach the original server that authorized the session, you'll need to route websocket (TCP) connections back to that original server via sticky sessions. Unfortunately AWS makes this extremely tricky and will require you to learn how to:
A) Modify elastic load balancer policies to forward protocol information
B) Split apart TCP connections from standard web requests using something like HA PROXY or NGINX. This is necessary in order to handle web socket UPGRADE requests properly, as you will be setting TCP to sticky and web requests to round-robin.
C) Attach your socket.io configuration to a common storage source, like Redis (elasticache).
Once you've figured out what's needed for AWS (or if you've got full control over request routing at your local datacenter), you'll want to architect your SOCKET application to use multicast rooms rather than direct socket messaging.
Example:
To send a message to users in game #4444, emit a message to room 'games:4444', rather than direct to the user's socket.
If your socket instance is configured using REDIS, REDIS will automatically take care of maintaining lists of people who are connected to your 'games:4444' channel. Otherwise you'll need to maintain the list yourself using a database or other shared mechanism.
Other than that, there are plenty of resources online that can help you figure out each step along the way. I'd start with understanding something like HA PROXY and how it can help split apart your SOCKETS from your web requests.

WebRTC Data Channel server to clients UDP communication. Is it currently possible?

Is it possible to use WebRTC Data Channels on Node.js in a way that mimics the functionality of WebSockets except using UDP?
In essence I want to have a server running Node.js with which browser clients can establish a full duplex bi directional UDP connection via JavaScript.
My question is the same as this one from 8 months ago. I repost it because the only answer was :
Yes, in theory you should be able to to do this. However, you'll need a node module that supports WebRTC data channels, so that you can connect to it like any other peer. Unfortunately, scanning through the current modules, I don't see one that implements the data channel.
Any of you know of such a module ? In my search I found some node modules with the words "webrtc" and "datachannel", but they didn't look like what was needed, they looked like they were meant for specific needs.
This project is very active, and seem to undertake the mission of importing the entire WebRTC stack into node.js
There's also this project but it looks pretty inactive.
Would love to know if that was satisfying and if you're doing such a project (as in the question) please link to github :)
We have implemented the exact same thing: a server/client way of using WebRTC. Besides we also implemented data port multiplexing, so that server would only need to expose one data port for all rtcdata channels.
A quick summary of how it is achieved:
We implemented in nodejs, using wrtc library. But the same principal could be applied to other implementations.
The server exposes a control port, so that the client will exchange SDPs with the server for establishing their data channel.
To support data port multiplexing, At the server, we modify both peer's SDK, so that
Client will always connect to the same server ip:data_port
We implement a UDP data proxy inside the server, so that it can be the bridge between the server webrtc engine and the client.
The code is at: https://github.com/noia-network/webrtc-direct

Socket.io - Socket connection between clients

Im looking form something to make socket connection between client, without pass through the server. Is there any node package to do this?. Server only send the other client socket, and the clients recieve and send data to each other..
Or, how can we make the implamantation. We need to make a server in client side, but we dont have node installed in the client..
The closest thing that currently exists in some form is not currently part of socket.io. It is called WebRTC and is implemented in Chrome currently. It allows the browser to connect with other browsers.
http://www.webrtc.org
The question is what kind of application is your client? If you are talking about ordinary webbrowsers you need to think about writing pluings (tough case).
If you are talking about clients you have more control then you should look at technique Puching the hole exploited by Skype or P2P apps.
http://it.slashdot.org/story/06/12/15/191205/how-skype-punches-holes-in-firewalls
In general the server is used for TCP sockets orchestration the acutall comunication go directly.

Socket.IO Server-Server Communication

We are using Socket.IO to communicate real-time statistics to connected browsers; however due to the architecture of a system we are building we want to allow both browsers and other nodejs servers to subscribe via Socket.IO for statistics. Would it be possible for me to create something like a custom transport for communicating via TCP to another Socket.IO server that had subscribed?
We want to continue to use Socket.IO's built in support for channels and subscriptions, but provide server-server via node.
Thanks for any suggestions!
I also posted on Socket.IO's GitHub Issues Page and got an answer there. Looks like I will be using Hook.IO to do what I need.
Thanks!

Categories

Resources