Download presentation
Presentation is loading. Please wait.
Published byAmbrose Peters Modified over 9 years ago
1
Casablanca: C++ on Azure @MaheshKrishnan Principal Consultant Readify @JohnAzariah Senior Architect MYOB AZR331
5
demo Getting started
7
var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); respose.end('Hello World!'); }).listen(8080, '127.0.0.1'); var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); respose.end('Hello World!'); }).listen(8080, '127.0.0.1'); Node.js Hello World example
8
using namespace http; http_listener::create("http://localhost:8080/", [](http_request request) { return request.reply(status_codes::OK, "text/plain", "Hello World!"); }).listen(); using namespace http; http_listener::create("http://localhost:8080/", [](http_request request) { return request.reply(status_codes::OK, "text/plain", "Hello World!"); }).listen(); Casablanca Hello World example
9
demo ‘nuff talk. Let’s see some C++
11
demo RESTful Azure Service
12
using namespace http::json;... value jsonObj = value::object(); jsonObj[L"Isbn"] = value::string(isbn); jsonObj[L"Title"] = value::string(title);... request.reply(http::status_codes::OK, jsonObj); using namespace http::json;... value jsonObj = value::object(); jsonObj[L"Isbn"] = value::string(isbn); jsonObj[L"Title"] = value::string(title);... request.reply(http::status_codes::OK, jsonObj);
13
using namespace http::json;... value jsonValue = request.extract_json().get(); wstring isbn(jsonValue[L"Isbn"].as_string()), using namespace http::json;... value jsonValue = request.extract_json().get(); wstring isbn(jsonValue[L"Isbn"].as_string()), Json => C++ object
14
storage_credentials creds(storageName, storageKey); cloud_table_client table_client(tableUrl, creds); cloud_blob_client blob_client(blobUrl, creds); cloud_queue_client queue_client(queueUrl, creds); storage_credentials creds(storageName, storageKey); cloud_table_client table_client(tableUrl, creds); cloud_blob_client blob_client(blobUrl, creds); cloud_queue_client queue_client(queueUrl, creds); Connecting to Azure storage
15
cloud_table table(table_client, tableName); query_params params; auto results = table.query_entities(params).get().results(); for (auto i = results.begin(); i != result_vector.end(); ++i) { cloud_table_entity entity = *i; entity.match_property(L"ISBN", isbn);... } cloud_table table(table_client, tableName); query_params params; auto results = table.query_entities(params).get().results(); for (auto i = results.begin(); i != result_vector.end(); ++i) { cloud_table_entity entity = *i; entity.match_property(L"ISBN", isbn);... } Reading from table storage
16
cloud_table table(table_client, L"Books"); cloud_table_entity entity(partitionKey, rowKey); entity.set(L"ISBN", isbn, cloud_table_entity::String);... cloud_table.insert_or_replace_entity(entity); cloud_table table(table_client, L"Books"); cloud_table_entity entity(partitionKey, rowKey); entity.set(L"ISBN", isbn, cloud_table_entity::String);... cloud_table.insert_or_replace_entity(entity); Writing to table storage
17
demo Deploying to the cloud
18
demo Text to Speech
19
Async File I/O Timers Binary Serializers JSON Parser & Writer Azure / IIS HostWindows Server Windows 7 / 8 IOCP PPLWinHTTP HTTP Client & Listener TCP Client & Listener Web Sockets Client & Listener UDP Client & Listener Apps & Libraries Azure Storage Windows Live Xbox Live C++ Actors Bing Maps Foundation Casablanca Lib Service Host Possible 3rd Party
20
http::client::http_client client(L"http://url/"); client.request(methods::GET, L"/foo.html").then( [=](pplx::task task) { http_response response = task.get(); //Do something with response... }); http::client::http_client client(L"http://url/"); client.request(methods::GET, L"/foo.html").then( [=](pplx::task task) { http_response response = task.get(); //Do something with response... }); Casablanca Client APIs with task library
21
Mandelbrot
23
http://msdn.microsoft.com/en-us/devlabs/casablanca.aspx (Casablanca) http://msdn.microsoft.com/en-us/library/hh279654.aspx (C++) http://msdn.microsoft.com/en-us/library/dd492418.aspx (PPL) http://social.msdn.microsoft.com/Forums/en-US/casablanca/threads (Forum)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.