I know that MeteorJS is an "isomorphic" web framework, which to my understanding means that code can run on both the client and server in different ways.
However, "server" here means a central server for all clients. If I'm making a quiz webapp, however, I need a central computer (for example to display the questions) to act as the "server" for a bunch of other clients. As in, using the quiz example, in a classroom setting, the student's computers would be clients and the teacher's computer the server.
Is this possible using Meteor? Can I deploy the same app but have it act differently depending on some setting or something?
What you ask for is quite possible. The most common way to achieve it is by using account roles: special privileges for some users. For example, if the teacher logs in (from any computer) the app would display the admin dashboard. alanning:roles is the de facto standard package for this purpose.
You could also possibly implement this by matching the IP address of the browser and the server, too. this.connection will tell you the client IP inside Meteor methods and publications, and Node.js can tell you the server IP. This way you don't need user accounts at all, but then all clients must connect to the teachers computer.
I'd go with account roles, I believe it's more reliable than comparing IP addresses.
Related
I make a web app so you can vote for the employee of the month for a supermarket, but they must be able to vote via their phone, I have created a database on mongoDB and host via Github Pages, my problem is that the database of votes does not receive the request when I try to vote via my phone, it works perfectly when I vote via Wifi but not via phone data.
the app is written in html and uses form tag, and javascript for everything else.
Github Pages hosts static pages from a GitHub repository.
That works well for apps that don't require any backed server; you can even do fairly complicated things in them (like write a Morse-code teaching app).
However, you're using MongoDB—that's a database. So you have a system that probably looks something like this:
[user] -> [webpage hosted on GitHub pages] -> [MongoDB database]
That database needs to be hosted at a location that is accessible to the GitHub pages page you load in your browser. GitHub pages is hosting your web pages in a place that's accessible anywhere in the world (which you know, since you're reading the pages on your phone over data). But if that database isn't accessible anywhere in the world, your webpages will fail to reach the database.
What URL are you using to reach your database?
I would guess it looks something like localhost:####, or some local IP (like 192.168.12.34:####). These addresses are accessible on your local network (your wi-fi), but not globally. When you connect over data, your webpages try to send data to your MongoDB instance at some IP address that doesn't exist on the cellular network. If that's the case, you need to think about hosting your database somewhere that can be accessed anywhere in the world, from any network. You can do that by exposing your MongoDB publicly (through port forwarding, etc), but that's almost certainly the wrong thing.
Instead, you probably want to set up a managed MongoDB instance—pay a service a few $ a month to host your database for you; you'll get an IP address or a domain name for your database that you can use. If you were to start writing an app in 2005, you would probably been told to pay for a VPS (Virtual Private Server) which is basically a computer with its own IP address; you could host your MongoDB on that VPS, and even serve your webpages with Apache or NGINX. That would cost about $5/month today. You could also buy a domain name for the VPS.
Apologies if this entirely misunderstands your problem, and also if this is more detail than you were looking for. Setting up a database-backed application isn't as easy as it could be.
HTML5 supports online web storage which can help in making our website to work offline. But, how can one share data between systems that are connected through LAN when offline?
The requirement is:
If offline, there will be a centralised system, through which all the systems of a particular group will be connected. Any update on one system will be reflected in all the systems in that group. When the centralised system go online, the data will be synced with a remote mysql DB.
And if online, all system will update to the remote mysql DB directly and hence always in sync.
How to get started for such a system?
You can't. This isn't a thing that HTML5 applications can do.
Specifically, there is no way for such an application to "discover" other instances of that application on the network, or to communicate with them, while offline.
Communicating with the "centralized system" you're describing in your question would require your application to be online. And if you're able to do that, the application doesn't need to operate in that fashion anyways!
Is it possible to get Client Computer name in asp.net web application ?
I don't want to use ActiveX object as it is not supported in all browsers.
I am building a Application which is going to hosted in Azure so it is not giving proper Computer name using bellow code.
string pCName=
System.Net.Dns.GetHostEntry(this.Page.Request.UserHostAddress).HostName
This code works only with intranet application. can any one suggest me solution or any alternative solution to get Client PC Name ?
You can get Computer names using codes if they are in a network(intranet) which works fine as you suggested.
At the same time when the system is accessed via internet there is no computer name rather Domain name.
I want to get the machine name of the client the request is being made
from. With ASP I can get the IP address. But I don’t know how to get
the name of the machine. Is there something I could do from the client
side?
No, the web browser client cannot determine the name of the machine.
Clients and servers should not trust each other. In the absence of
authentication evidence, clients must assume that all servers are run
by evil hackers and servers must assume that all clients are run by
evil hackers. Once you accept that fundamental design principle then
it becomes much easier to reason about client-server interactions.
Think like an evil person!
More reference on the topic (Retrieving the system name) , you can refer :
Stack Overflow posts :
Get Client ip address and system name
How get client (user) machine name (computer name) with jQuery or JavaScript or server-side codes.
Hope that will put more light on the issue.
You could try
Request.ServerVariables["LOGON_USER"];
Form
System.Web
Ultimately what I would like to to is build a Javascript app that runs in the browser, and is able to communicate to other users running the same Javascript app on other machines within the same network. I've been reading up on and playing around with Websockets and webRTC, but they both require a server at some stage of the connection process. I have also looked at PeerJs and OpenPeer, but they too seem to rely on webRTC which in turn requires an intermediate server to setup the connection.
If the users are not connected to the Internet (or to a network running a local server) it doesn't seem possible to use either of the above techniques, right?
Basically what I'm thinking is this:
User A and User B are on two separate machines on the same LAN/WLAN, not connected to the Internet.
User A opens up the app/page in his browser.
User B opens up the app/page in his browser.
User A enters User B's local IP address in a textbox and clicks on "Connect".
User A and User B can now send messages to each other.
Is this possible today? Or is there something being developed that would enable this in the near future?
This is not possible to do directly inside of a browser.
Standard HTTP interaction is based on a request-response model. Web browsers act as the client, sending requests. They are not designed to be able to handle HTTP requests and send responses accordingly, that job belongs to a server.
I know this is an old question, but in case someone finds it relevant:
Today this is possible using WebRTC, a JavaScrip, peer-to-peer, real-time communication protocol.
A library that's available at the time of writing is PeerJS, which supports most browsers, for now except Safari.
PeerJS handles some of the complicated, behind-the-scenes stuff related to NAT and firewalls so that you can send data between two JavaScript clients.
I am writing a simple javascript game for a webpage. I am going to convert it to the desktop using tidesdk. I would like to allow players on different machines to play each other without the need to communicate through a server.
Is this possible in general? Is this Sockets?? Do you have any links of this being done with javascript code?
Is this possible with TideSdk? Do you know of any links to examples of this being done wiht TideSdk?
How do the players know what ip address/port their machine is on so they can give it to the other player?
I am sorry these are vague and open questions, but I don't really know where to start looking for this stuff, as I don't really know what the stuff I am looking for is called.
... Oh, and I don't want to use any third party stuff if I can help it. Maybe the jquery at a push.
This would be impossible with the APIs provided by web browsers (you would need to use something like Socket.IO and communicate through a server, as others have said). Fortunately, since you are using TideSDK, it is possible as long as you don't need a lot of network efficiency. You will need to provide a server, but it will not have to be powerful enough to host the actual games.
The General Client and Server Method
There are other ways to organize a network, but you can look those up if you think they'd be easier to implement.
Your server will host the actual game download and provide matchmaking capabilities. The clients that people download will contact this matchmaking server to find others who want to play.
The matchmaking server should select one of those clients to be a host for the others. Finally, the matchmaking server will tell the client selected as a host that it is the host and give it everyone's connection information (ports and IP addresses) while giving the other clients the connection information for the selected host. The host will connect to the other clients.
The host computer will be the only one that actually does any processing of gameplay, and the other clients just display whatever information the host sends them. The clients render the current state of the game from each player's perspective on their respective computers and capture user input, which is sent to the host for processing.
Implementation
TideSDK provides a Ti.Network.TCPSocket object which can make raw TCP client connections to TCP servers. Unfortunately, it does not also provide a way to make raw TCP servers. Instead, TideSDK provides a Ti.Network.HTTPServer object, which implements the HTTP protocol server over TCP, and a Ti.Network.HTTPClient object, which provides an HTTP client (it is actually just an abstraction over the normal AJAX request API). You can use the provided HTTP server on the host computer and directly connect to it on the clients using the provided HTTP clients. Data will be exchanged using the HTTP protocol. As far as I can tell, this is your only option here.
I did not find any example code out there (beyond what is in the TideSDK documentation) but you might find some if you are really interested.
Next Steps
If I wanted to go ahead with using TideSDK, I would do the following:
Tell the developers of TideSDK that you are interested in a TCP server socket. A raw TCP connection would be much faster than HTTP.
Test out the HTTP connection and find out if it is fast enough for my game.
Yes it's possible in general, and sockets are what you need. Although I don't think it's possible in practice, here's why.
Normally in a P2P game, there would be a server that knows who is online, and what their IP is. When new players connect to the server they will see a list of other users, they can select who they want to play.
Without having the server, there will be no way for users to see who is online, and to answer your 3rd question:
How do the players know what ip address/port their machine is on so they can give it to the other player? It doesn't matter if they can find their own IP, they have no way to find the IP of the opponent (without calling them on the phone :)).
So, if you want to build a game, then you'll need a server. I suggest Node.JS alongside Socket.IO