Receive PubNub subscribe message and insert MongoDB database - javascript

I'm trying to develop a small system with a easy architecture. In this case I have one simulator that generate random data and publish this data on PubNub. Otherwise, i have too two subscribers: one web based dashboard and MongoDB database.
At this moment, I developed the simulator and the dashboard. The next stage is receive the PubNub subscribe data and insert into MongoDB.
My issue is how I can do this remotely? What is the framework that I should use? I saw many tutorials that start MongoDB DB by terminal on local machine, remotely how this works?
Someone can give me a full explication?
Regards,
Note: I use PubNub JS SDK, my dashboard was developed in HTML, CSS and JS

Related

Firebase authentication users

I want to use the users from MySQL in my PHP application for chatting with each other and using firebase as a datastore. For example, there is a table of the user in PHP myadmin my website is also in PHP and my firebase module is in javascript.
I want to implement a functionality of chatting with real-time response time
You may need to write a NodeJS application top run in the background of your server that reads the MySQL DB and writes to Firebase. The NodeJS Firebase module is very easy to use, so adding to a Realtime DB will be easy.

How to list peers to be connected to video chat on PEERJS and Angular 4?

I've followed the tutorial over building video chat with usage of PeerJs and Angular 4 (http://tphangout.com/angular-2-videochat-using-peerjs/)
Tutorial descibes it for ANg2 , but i was able to launch it with Ang 4
I plan to have a user, which sees the list of other others and can connect to any of them.
Decided to check if someone done this and might advise on following:
1) What is the best way to list users connected to Peer Server? Can this be done with some query ?
2) How to refresh the list if other users are available or disconnected?
So far, easiest way for me would be to store id of connected users in DB and query upon user visiting specific route.
ANy suggestions?
PeerJS is quite outdated, lib wasnt renewed for quite long. Ive researched and there are other options like simplewebrtc (works in chrome, ios etc) , easyrtc and others. The problem is that for those libraries there are no demo projects with Angular 2/4.
Thanks and Regards
You should save the peerjs id's to a database table, and then each client can show a list of them.
Have a look at https://github.com/mikkelking/meteor-video-call
Which is written in Meteor and Angular1.5 - it's really easy to run up, just follow the instructions (install Meteor first). It uses Meteor's reactive database to do live updates of the web pages. It uses the public peerjs server, and will only work on localhost - use Firefox for one end and Chrome for the other end of the video call.
You can ask more me questions if you want.

helping inserting entries to Azure DB

Im just starting out using Azure and i have minimal experience with SQL, so I'm a little confused. I set up my Azure Webapp to pull from a Git repository on bitbucket. I successfully linked those two together, and pushes made to bitbucket update my site. What I am having trouble doing is linking my database on Azure to this site, so that I can make data entry forms and insert that info as records onto this database. Im just starting out simple to learn the basics. I have a table names Users with the elements, id(which is set up as IDENTITY so it sequentially creates a unique id number), username, password, and email. I can pull the info from the HTML document and everything just fine, but how do I correctly link my DB and its tables using HTML, js, and azure? Ill post any additional info that will be necessary, i dont even know where to begin on this really.
Ill also add im using Visual Studio for creating tables and entities and most DB management.
Thanks in advance.
How to access your database depends on the database you are using and the server side programming language. From the tags you used in your question I assume you are using the mysql database provided by clear db through the Azure Management Portal. You can not access your database right from JS. As you are using VS I guess you are using asp.net on the server side. If using asp.net this article might help: https://msdn.microsoft.com/en-us/library/ms178371%28v=vs.100%29.aspx
If you created a ms sql database through the SQL Database service in MS Azure you also need to check the firewall settings to allow access from your app.

Frontend for Hibernate and SQL 2008 Connection through JSP or JS

I am working on application which uses GWT as front end and Hibernate 4.0 Framework. I am using SQL 2008 (R2). My application is purely DB Driven. And the application would get launch at multiple portals simultaneously with different DB. Right now, the problem which I am facing is, I have to deploy as many wars as many DBs are there for each Portal. Is there any way with Hibernate to make it configurable? Means After loading my Homepage after entering db name, db user_name and db password it gets connected to the DB.
I would also bring you notice that my Homepage gets loaded in JSP. And after login it is calling GWT Entrypoint.
As said by #ToddMurray in the comments, you should use a configurable JNDI dataSource. It's the preferred way to go with containers like JBoss. See here for a config example.
Another way to go is with Hibernate properties: read the documentation here.

Offline Web Apps and database sync

I need to ask for some advice regarding offline web applications and database sync.
Offline Scenario
We have a web site (HTML5) that needs to operate in an offline mode for extended periods of time with complex data, the product owner does not want the data put into local storage.
We have two options as I see it;
Use javascript to detect if we are offlline and if so point the urls to a local web server that replicates the stack at the data center and writes to an offline db
◦Biggest stumbling block is how, on the first load if you are offline do you get the location (URL) of the local web server? i.e. user goes to www.xyz.com, but you are offline so
Question 1: how to redirect him to localhost.xyz.com via javascript for that first call
Point all calls at the client , offline or not to a wcf service that checks offline status at the NIC and redirects every web and service call to the correct place
◦seems like a big job,
Question 2: is there any product/ opensource project you guys know off that does this?
Sync Scenario
•They want to use MS sync framework
◦But they have many clients syncing to different database, so you either need 1 sync service per client or some way to identify who the client syncing is and point them to the correct place
◦Need to minimize locking during sync as other clients are using the same tables during sync
Question 3: can the sync framework be extended to even do this
Question 4: What other options exist for database sync on MS platform?
Thanks
If the user puts the URL into their browser, they are going to go that URL. There is no javascript at that point. You would only have Javascript once a page is loaded. You will have to search for a better solution.
Here is an idea: Users ALWAYS go to the local website, and if the remote site is up, then you redirect them.
In terms of MS sync I do not know what it is, so I cannot help you there.
Re What other options exist for database sync on MS platform: there is also SQL Azure Data Sync, a windows azure web service. It is actually built upon the Microsoft Sync Framework you refer to.
There is an example in the book "Programming Microsoft SQL Server 2012" by Leonard Lobel & Andrew Brust (MS Press) - chapter 13 covers building occasionally connected systems that incorporate SQL Azure Data Sync, Windows Azure and the Windows Phone 7 development platform. In the sample solution, on the back end, an on-premise SQL Server database is kept synchronized with a public facing SQL Azure database in the cloud using SQL Azure Data Sync. The cloud database is exposed using WCF Data Services (also hosted in the cloud by deploying to Windows Azure) and consumed via OData by a mobile client application running on a Windows Phone 7 device. The sample solution detailed in the chapter demonstrates how these technologies work to keep data in sync across on-premise SQL Server, SQL Azure databases in the cloud, and local storage on Windows Phone 7 devices.
Sync Framework do not lock tables when synching.
depending on what client database you want to use on the client, you can either use Sync Framework itself which works with MS databases (SQL CE, SQL Express,LocalDB,SQL Server, SQL Azure) or you can use the Sync Framework Toolkit
whichever platform you choose, i would suggest simply writing to the local store and synching it rather than dynamically choosing which store to use when.
for example, if you went offline and you wrote to the local store. then your network monitor detects you are back online and redirects you to the online service, what would you do with the data you stored locally? or you transacted online and you suddenly went offline, how recent/updated is the local store for you to actually starting working agaisnt it?
You could use Service-Workers to make the website work while users are offline. see: Making PWAs work offline with Service workers. This allows your website to work for the users if they are offline (they need to have internet at least once every 24 hours).
Service-Workers also allows you to detect when your user is offline or online, and you can for example use the IndexedDB to store your offline changes and then synchronize them when the user is online again.
I don't know about MS Sync.

Categories

Resources