Using Linux C++ Server to interact with JavaScript

Currently, I have a client application built in Flash running on a server application developed in C++ for Linux. These two communicate via a TCP socket, with the server handling all game logic and client communication.

As part of deploying my application to a website, embedding the SWF file has been straightforward and is working as intended.

My goal now is to save statistical data about users by using Facebook login to uniquely identify them and store their information in a MySQL database.

The challenge I'm facing is how to transfer the Facebook user information from the JavaScript component of my server application (index.html using Apache) to the C++ portion of the server where the game logic and database management reside. This step is crucial for me to obtain a user's unique ID for database purposes.

Is it feasible to relay this information from JavaScript to the C++ application effectively?

Answer №1

If you want your C server to function as a webserver, it can accept connections using the HTTP protocol and then interact with Ajax to send data. It's important to ensure that your server includes the response header

Access-Control-Allow-Origin: yourdomain.com
, replacing yourdomain.com with the domain where you host the HTML+JS page. This is necessary for allowing cross-site requests because the C server listens on a different port and possibly a different address than the webserver.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating responsive tabs that transition into a drop-down menu for mobile devices is a useful feature for

I am looking to create a responsive tab design that drops down like the example shown below: Desktop/Large Screen View https://i.stack.imgur.com/hiCYz.png Mobile View https://i.stack.imgur.com/gRxLv.png I have written some code for this, but I am unsure ...

Using AJAX to remove data from a database

My PHP code snippet is displayed below: AjaxServer.php include '../include/connection.php'; // Check for the prediction if(isset($_POST["delete_me"]) && $_POST["delete_me"]=="true"){ $id = $_POST["id"]; $table = $_POST["table"]; ...

Discovering the clicked button in a partial view during an onSuccess Ajax call

Within my partial view, I have implemented two buttons: Save and Preview. Both buttons are functioning as expected, with Preview enabling widget preview and Save saving data to the database. However, I am encountering two issues: I am unable to determine ...

Steps for creating a two-dimensional arc

I want to input some pre-determined acr values from another program and replicate them in three.js Currently, I'm using code I found on this site to draw the arc, although it might not be the most optimal solution. function DRAWarc(){ ...

Using a friend template function causes an issue with undefined symbols and results in a bug

Background: The objective of the program is to create a template for a single linked list where information can be accessed by using a key. The intention was to incorporate a split function that takes a source sequence, begins splitting it at the specifie ...

How do I modify the height of a q-select component in Quasar?

I have been struggling to change the q-select in the quasar framework, despite numerous attempts. <q-select v-model="site1" outline dense class="selection" /> :deep(.selection .q-field__control) {font-size: 13px; width: 250px;} ...

Valgrind can identify memory leaks in a program without causing it to crash

Can Valgrind identify reachable memory leaks without having to stop the program? In other words, is it possible to determine this information before the program finishes executing? ...

Updating the scope in Angular when changing the image source using ng-src is not working

A snippet inside my controller looks like this: $scope.onFileSelect = function($files) { for(var i = 0; i < $files.length; i++) { var file = $files[i]; $scope.upload = $upload.upload({ url: '/smart2/api/files/profi ...

Tips for creating C++ classes that represent trees and nodes

Currently facing numerous challenges with destructing the tree and performing operations like printing due to recursion issues. The problem arises when recursively calling print on left or right subtrees because they are being treated as individual Nodes i ...

Express.JS failing to save data to file when using NeDB

Currently, I am developing a bulk import feature for my personal password manager and I have encountered a problem. The issue arises when trying to import an array of passwords using the forEach() method to iterate through each one. After calling the inse ...

Is it possible to integrate a jQuery function within PHP code when encountering a "is not defined"

I am looking to implement the jQuery-confirm dialog in place of using a JavaScript alert generated by PHP. However, when I execute the following code, I encounter the following error message: $ is not defined echo "<script>$.alert({title: ' ...

Performing repeated insertion using a foreach loop

I am seeking a way to add multiple rows into a database table. This is the HTML code: <tr> <td style="display:none"><input type="text" rows="4" name="teste[]" value="<?php echo $produto8["Id"]; ?>"></td> <td><textar ...

Looping through JSON data to dynamically generate DIV elements

Currently, I have in my possession a JSON array that contains various values. To convert this List to JSONArray, I employed the JSON-lib and some groovy classes. Along with the JSON array, I also have a JS file and a JSF for the front end. My task at hand ...

Node.js causing error: TypeError - Unable to access property 'forEach' as it is undefined

Currently in the process of developing my initial node/express application and closely following this tutorial. I have reached a stage where I am attempting to retrieve all JSON data, store it in an array for transmission to the template, and eventual ren ...

Exploring the inheritance of directives and controllers within AngularJS

I'm struggling to grasp the concept of inheriting a parent controller from a directive. In my setup, I have a simple example with a controller named MainCrtl. This controller is responsible for creating and removing an array of directives called inner ...

In the Win32 environment with Visual Studio 2010, a null dereference can cause call stack corruption, but this issue

Working with VS2010, I developed a simple win32 console program that includes a null dereference: int _tmain(int argc, _TCHAR* argv[]) { if (*(int*)(NULL) == 5) { printf("foo"); } return 0; } When running this program in x64 configura ...

Compiling C++ code for ARM architecture leads to runtime crashes

Currently, I am addressing a bug related to the Android multimedia framework's lower C++ library. At a specific point in the code execution, the system crashes. if (((*pChar) >= _T('a')) && ((*pChar) <= _T('z'))) { ...

How can I get stringstream to read integers separated by blank spaces instead of just the first digit?

The relevant code snippet is displayed below: string output; char letter, number, symbol; cout << "Please enter a letter, number, and symbol separated by spaces: "; getline(cin, output); istringstream(output) >> letter >> number >> ...

What is the most effective way to assign multiple functions to the onClick event of a button, based on a specific property,

I have a special button that generates a specific type of code when rendered: <button>{this.props.text}</button> This button is named ButtonCustom. In the render method of the main container, I am trying to achieve the following: function my ...

Collaborating on interconnected documents: population dynamics and sophisticated modeling techniques

As someone who is fairly new to these technologies, I'm unsure if I am doing this correctly. I am attempting to display the name of the category in the table instead of the id (which is from the ObjectId schema field) for all the Category documents r ...