Sei sulla pagina 1di 147

… in ACTION!

The next generation application platform for business


Embarcadero
Reinvents Business
Application Development!

Pawel Glowacki
European Technical Lead for Delphi and RAD Studio
http://blogs.embarcadero.com/pawelglowacki
Agenda
• 0830-0900 Registrations
• 0900-0915 Embarcadero Overview
• 0915-0930 Introduction to AppWave
• 0930-1030 RAD Studio XE2 Overview
• 1030-1045 Coffee break
• 1045-1145 FireMonkey Deep Dive
• 1145-1215 Delphi 64-bit and VCL Styles
• 1215-1330 Lunch & coffee
• 1330-1400 LiveBindings Deep Dive
• 1400-1430 RAD Cloud Services
• 1430-1500 Q&A
Embarcadero Overview
Who is Embarcadero?
Embarcadero provides
database professionals
and application developers
with award-winning software tools
to design, build and run their systems
in the environment they choose
Developers, DBAs, and
Architects
Embarcadero Has You Covered
Introduction to AppWave
RAD Studio XE2
Overview
The ultimate application
development suite for Windows,
Macintosh, Mobile, and Web
Fast Native applications for Windows,
Macintosh, Web and Mobile
• Write app once, compile
for multiple platforms
• Data-rich, Component-based
• Delphi and C++
native code performance
• Delphi for 64-bit Windows
• VCL Styles
• RadPHP for full
visual web development
Introducing
The Next Generation Business Application Platform

• Stunning HD and 3D
Business Applications
• Native Power and Performance
• Connect with any Data
and Services
• Full Suite of UI Controls
• Visualize Live Data
• Styled Vector UIs
without coding
• Communicate with Animations
• No-Code Hardware Effects
Applications that Connect Everywhere
• High-speed connectivity
to popular databases
• Multi-tier applications
• Clients on multiple
computers and devices
• Connect to the world
of data, services,
and the cloud
Mobile choices for you and your users
• Native mobile apps for DataSnap
– iOS, Android, Blackberry,
and Windows Phone 7
– Delphi and C++Builder DataSnap Servers
• Mobile-optimized PHP web apps
– Web apps that look great
– Web apps that work great on mobile
devices
– Package applications for distribution
– Sell on Apple App Store and Android
Marketplace
And one more thing…
Create native iOS apps
• Use the RAD Studio XE2 IDE
• Create a Delphi FireMonkey application
• Compile for iOS
• Run on iPhone, iPad, iPod Touch
• Your rich app, your rich data, everywhere
Demonstrations
RAD Studio XE2

…and more!
Delphi XE2

The fastest way to build native Windows, Mac and


iOS applications
New in Delphi XE2

64-bit Windows Target Windows, Create visually


development Mac, and iOS stunning applications

New and updated tools


Connect with more including Fast Report and
VCL Styles
data and services Documentation Insight
C++Builder XE2

Rapid visual C++ development environment


New in C++Builder XE2

Target both Windows Create visually C++ audits and


and Mac stunning applications metrics

New and updated tools


Connect with more including Fast Report
VCL styles
data and services
RadPHP XE2

The fastest way to build applications for Web,


Facebook and mobile
New in RadPHP XE2

Create iOS and


JQueryMobile visual, Android applications Zend Framework
component-based that you can sell on components for email,
development of mobile the Apple and Android feeds, Google docs
optimized web pages app stores and more
Embarcadero Prism XE2

Pascal development for .NET and Mono


New in Prism XE2
• All new Oxygene Compiler 5.0 from RemObjects
• Inline errors in editor with details, ranges & notes
• Live compiler errors in the code editor
• Fix-It support for selected new errors
• Language soft interfaces and duck typing
• Anonymous interface implementation
• Enhanced Oxidizer integration
RAD Studio XE2 Developer Toolbox

Deploy high performance


Document your Delphi code database applications with
with Documentation Insight InterBase XE

Quickly design and generate Incorporate graphs and charts using


reports with FastReport TeeChart (VCL & FireMonkey)
RAD Studio XE2 Developer Toolbox

Compare files with Beyond Automate your build process


Compare differ with FinalBuilder

Ensure high performance with Build Web applications with


AQtime IntraWeb
RAD Studio XE2 Developer Toolbox

Locate problems more quickly Use InstallAware to create


with CodeSite logging your software installers

Add a professional look with glyFX Get a jump start on component-


Icon Library based internet development with
IP*Works
RAD Studio XE2 Developer Toolbox

Create reports with Indy (Internet Direct) – Internet


Rave Reports component suite for popular
internet protocols

Partner DVD available online with


even more free tools!
RAD Studio XE2 Editions for Every Developer

• Starter (Delphi/C++Builder)
• Professional
• Enterprise
• Ultimate
• Architect
RAD Studio XE2
The ultimate application development suite for Windows, Mac, mobile and Web

• Deliver Fast Native Applications


on Windows, Mac, Web and Mobile
• Speed Up Your Development Process with RAD
• Create Visually Stunning and Interactive
Business Applications
• Build Applications that Connect Everywhere
• Break Free from Grids – Visualize Live Data
Coffee Break
FireMonkey Deep Dive

The Next Generation


of Business Application Development
Consumer Software Renaissance

• Media and graphics Rich user experiences


• Intuitive and interactive – easy to learn
• Simulated real world physics
• Touch and motion interaction
Business/Industry Software Stuck in Past

• 90’s Windows user experiences


• Confined to mouse/keyboard interaction
• Complex to learn - slow to use
Key Markets

• ISV’s / Packaged Software • Energy


• Healthcare / Medical • Aviation & Automotive
• Manufacturing • BioSciences
• Financial Services • Pharmaceuticals
• Telecommunications • Utilities
User Experience
FireMonkey

Business SW
is stuck here
VCL
UE Richness

MFC
UE Performance
Introducing… FireMonkey!
FireMonkey

• Rich Application Platform for Business


• Native CPU and GPU performance
• Built-in Enterprise Database connectivity
• Windows, Mac, and iOS
Managed RIA

FireMonkey is not …

Game
HTML5/CSS3 Engine
FireMonkey is…
App Development Platform

C++Builder Delphi

Windows Mac OS iOS


VCL and FireMonkey

Win Mac iOS


VCL
FM
Native CPU/GPU Application Platform

• Compile natively to Windows, Mac, and iOS


• Application, Database, and Animation are CPU powered
• All UI, Graphics, and Effects are GPU powered
HD Forms

• High performance GPU powered Scalable Vector Uis


• Maximum resolution on any device
• Hundreds of visual UI components
• GPU based Style Engine to control UI look & feel
• HUDs with transparencies and transition effects
3D Forms

• GPU powered 3D Forms


• Hardware based lighting, textures, and animation
• 3D Forms can contain HD UI elements and effects
Effects & Animation

• 50+ Photoshop-like GPU Effects


• Simultaneous multiple effects without performance hit
• Path based animation for all HD and 3D UI and graphics
FireMonkey Overview
• Cross-platform
• Modern themed/skinned UIs
• Real-time image and animation effects
• Direct2D, D3D, Quartz and OpenGL
• Native Delphi and C++
• 100% Object Pascal Framework
FireMonkey technology
• Mac
• HD use Quartz
• 3D rendering on Mac is OpenGL
• Windows
• Direct2D for HD
• Direct3D for 3D
• FireMonkey use GDI+ for HD vector
forms/controls, when Direct2D is not
available
“FireMonkey” – HD, 3D, and GPU
• FireMonkey takes advantage of GPU whenever possible

• HD Form can be rendered on a computer without a


GPU with a few restrictions:
– No TViewport3D, No Shader based Filters

• A 3D Form requires a GPU - performs sophisticated


transitions and manipulations of the user interface…

… in other words, a 3D form may be the best


choice for building a sophisticated HD user interface
“FireMonkey” Architecture
• TFmxObject = class(TComponent)
– Create, destroy and release object
– Cloning, storing and loading object from a stream
– Child object manipulations (add, remove, search)
– Free notifications
– Abstraction layer for tab order
– Support for FireMonkey resources
– Support for FireMonkey animations

• IControl
– Handles Focus, Mouse and Keyboard events
– Implemented by TControl and TControl3D
“FireMonkey” Architecture
• IRoot
– Interface for top-level containers
– Handles Focused, Captured, Active controls
– Implemented by TCustomForm

• IScene
– Container interface for 2D objects
– Implemented by TForm, TCustomLayer3D

• IViewport3D
– Container interface for 3D objects
– Implemented by TForm3D, TViewport3D
FireMonkey Styles
• FireMonkey Stylebook
– Any object inherited from TBaseObject
– Set StyleName to identify
– Found using FindStyleResource method from parented object
– Stored In / Loaded From a stream file

• FireMonkey Styles
– A collection of FireMonkey resource style
– WPF type of implementation
– Styles can be inherited, saved, loaded
– Look and Feel style files for Win7, MacOS, iOS and custom
themes
“FireMonkey” – Animation
• Used to modify property values over time
• Machine speed independent
• Can be looped and / or reversed
• Can follow a variety of time / value curves
• Can be triggered by MouseOver, Focus,
Visibility, etc.
“FireMonkey” – Effects / Filters
• Can be applied to bitmaps
• Can be applied to controls
• Can be triggered by MouseOver, Focus,
Visibility, etc.
• GPU shader based implementation
3D Programming
• One object model to target multiple platforms
• FM uses right-handed orientation in 3D
• Hardware acceleration
– Windows – DirectX
– MacOS – OpenGL
– iOS – OpenGL ES
FireMonkey and Cross Platform
• FM is a platform that supports
– RTL
– GUI
– Database
– Operating System
• Compile / Run on all platforms we support *

• * subset for mobile platforms


Fire Monkey - Demos
• Your first FireMonkey App
• Windows
• Mac OS X
• HD / 3D
• GPU/Shaders
Summary
• FireMonkey - The Next Generation Business
Application Platform
• Fully harness the powerful GPU graphics hardware
• Rapidly build visually spectacular applications
• Invest in one platform and deploy to numerous OS-s
• Delphi and C++ compiled, native executable
• Fully programmable animations and effects

• Your imagination is the only limit !!!

• Go FIREMONKEY !!!
Live Bindings

Deep Dive
What is LiveBindings?

“Provides a way for developers to create a


read/write link between components/objects
and their data in the the application.”
LiveBindings Overview
• Supported by FireMonkey and VCL
• Based on relational expressions, called binding
expressions
– Can be unidirectional or bidirectional
• Can be used programmatically or visually
• Is all about control objects and source object
LiveBinding Engine
• Allow developers to create live binding in run-time between
components/objects at design-time.
• The LiveBinding visual components use the engine:
– TBindScope for bindings to components
– TBindScopeDB for bindings to databases
– TBindingsList for holding of binding lists
• A number of conversion services in the box and allows to create
new conversion service
• Automatic updates
– Expressions are automatically re-evaluated when a variable (e.g.;
property) referenced by an expression has changed value.
– Requires external notification
LiveBinding components
• TBindScopeDB – magic binding
– Bind data from DataSet to components
– “Link to DB Field” wizard create the expressions to bind the data from DataSet
to components

• TBindScope – non-dataset binding


– Bind data between components/objects
– Support single object or collection of objects

• TBindingsList
– Hold the binding lists
– Manage the list of methods and output converters used by the expression
LiveBinding Scenario
SOURCE CONTROL
TField TLabel

Source Expression Control Expression


DisplayName Text

LiveBinding
Engine
Binding Expression Editor
64-bit and VCL Styles

Deep Dive
Delphi 64-bit
What’s the same?
• Integer, Longint, Cardinal – still 32bits
• Int64, UInt64 – still 64bits
• UnicodeString, AnsiString, WideString
• Exceptions
• Runtime Library (RTL)
• SysUtils, Classes, etc…
Delphi 32 and 64-bit Type Sizes
Signed types Delphi/32 Delphi/64
ShortInt 1 byte 
SmallInt 2 bytes 
LongInt 4 bytes 
Integer 4 bytes 
Int64 8 bytes 

Unsigned types Delphi/32 Delphi/64


Byte 1 byte 
Word 2 bytes 
LongWord 4 bytes 
Cardinal 4 bytes 
UInt64 8 bytes 
What’s different?

• NativeInt, NativeUint – 64bits


• Pointer (all pointers) – 64bits
• Dynamic Arrays – 64bit indexing
• Floating point math - Double
Delphi 32 and 64-bit Type Sizes
Signed types Delphi/32 Delphi/64
NativeInt 4 bytes 8 bytes

Unsigned types Delphi/32 Delphi/64


NativeUInt 4 bytes 8 bytes
Delphi 32 and 64-bit Pointer Types
Pointer types Delphi/32 Delphi/64
Pointer
String
Class instance
Class reference
Interface
AnsiString 4 bytes 8 bytes
WideString
UnicodeString
Procedure pointer
Dynamic array
PAnsiChar
PWideChar
PChar
The CPU – Programming model
Instructions and Addresses
• 64 bit address space
• Limited by physical hardware
• Same core Intel instruction set
• New REX prefix for 64bit instructions
• RIP-relative addressing
• Jumps – relative +/- 2GB
• 16 byte stack alignments

• Online resources
• http://msdn.microsoft.com/en-us/magazine/cc300794.aspx
• http://msdn.microsoft.com/en-us/library/7kcdt6fy.aspx
What does this mean for Delphi?
Don’t panic!
Delphi 64-bit on Windows
• Same Windows API
– CreateWindowEx, PeekMessage, etc..
• Same Delphi RTL
– SysUtils, Classes, Generics.Collections, etc…
• Same VCL
– Forms, Graphics, Controls, Menus, etc..
Pre-Defined Conditionals
• Category Identifier dcc32 dcc64
• Compiler DCC defined defined
VER230 defined defined
• Platform MSWINDOWS defined defined
WIN32 defined not defined
WIN64 not defined defined
• CPU CPU386 defined not defined
CPUX86 defined not defined
CPUX64 not defined defined
• Availability ASSEMBLER defined defined
UNICODE defined defined
Delphi 64-bit on Windows – some gotcha’s
• SizeOf(Pointer) <> SizeOf(Integer)
– Integer<->Pointer casts will break in 64bit
– SizeOf(THandle) = SizeOf(Pointer)
– All Handles = SizeOf(Pointer) (HWND, HDC, etc..).
• All code in process must be 64bit
– Must have 64bit versions of external non-Delphi libraries (DLLs)
• One, and only one, calling convention
– register, pascal, cdecl, stdcall are ignored.
• safecall is still “special”
• Old “pointer math” code may break
– Works in 32 and 64bit: MyPtr := PByte(P) + 10;
• TList’s internal FList is now a TPointerList. Used to be a PPointerList.
Removing ^ should be sufficient to port from 32-bit to 64-bit.
• Tag property is now a NativeInt (32-bit vs 64-bit)
Delphi 64-bit on Windows – some gotcha’s
• Inline Assembly
– Cannot mix asm blocks with Pascal code
– Only procedural level asm blocks supported
– Stack must be 16-byte aligned at each call instruction
– Define locals for temp storage
– Do not modify the RSP stack pointer
– New unified calling convention. First 4 parameters in registers,
RCX, RDX, R8, R9 (or XMM0-XMM3)
• Exception unwinding
– No change for pure Delphi code. Exceptions function identically.
– Inline Assembly can cause exception unwinding to fail if not
properly written.
• SHL/SHR – 32-bit values (Integer et al) will only shift in 32-bit space.
64-bit values will of course shift in 64-bit space.
• No Extended type in 64-bit. Use TExtendedRec80 if necessary (binary
files with Extendeds in them for instance)
Windows API gotcha’s
• SetWindowLong / GetWindowLong should
be replaced by SetWindowLongPtr /
GetWindowLongPtr for GWLP_HINSTANCE,
GWLP_WNDPROC, etc… as they return
pointers and handles.
– Pointers passed to SetWindowLongPtr should
be type-casted to LONG_PTR and not to Integer
/ Longint.
• SetWindowLong mapped to
SetWindowLongPtr in Windows.pas.
– Calls to our declaration of SetWindowLong are
safe, as long as they are cast correctly.
Windows API gotcha’s (con’t)
• Use explicit casts to WPARAM and LPARAM
where appropriate.
– Example: Passing pointers through
SendMessage SendMessage(hWnd,
WM_SETTEXT, 0,
LPARAM(@MyCharArray));
• Use LRESULT to cast message
results
– Example: Message.Result :=
LRESULT(Self);
• Message cracker records
(TWMxxx) changed
– Alignment changes and field-size
changes
What can I do today?
• Find all Integer<->Pointer casts, including
Integer<->instance casts.
– Check for Pointer size assumptions
• Ensure external dependencies are also 64bit
– Image/bitmap libraries
– Hardware interfaces libraries
– ActiveX controls
• Consider rewriting Assembler in pure-Pascal
– Better future portability (think ARM CPUs…)
– Rely more on algorithmic performance rather
than raw assembly performance.
• Make sure you know what bit-size (32 vs 64)
you’re shifting with SHL/SHR.
VCL
What’s New in the VCL?
• 64-bit
• VCL Styles
VCL Styles
Themes in Delphi/C++Builder XE and
earlier
• Only 1 "theme" supported (native Windows)
• 3rd party products required to change look of VCL
apps
• Current “skinning" products for Windows
common controls
– Requiring hooking WndProc's
– Intercepting control messages
• Separate controls needed for "custom" controls
– TCustomControl / TGraphicControl descendants
VCL Styles
• Multiple styles provided/supported
• Custom style file creation
• Custom style classes
• Pluggable style engine
• Works with TWinControl and TGraphicControl
descendants
VCL Styles
• TThemeServices replaced by TCustomStyleServices
– Extends TThemeServices with more parts, states and methods
• TStyleEngine
– Processes control messages
– Calls StyleServices to render parts
• TStyleManager
– Provides services such as
• LoadFromFile
• LoadFromResource
• RegisterStyle
• RegisterStyleClass - Associates file extension with Style class
• SetStyle
• Style selection
• Style engine selection
• Providing custom styles
– Create style file (using provided style building tool)
– Implement TCustomStyleServices descendant and render parts directly
What can’t be styled?
• TMainMenu/TPopupMenu (main menu bar is
styled, but not the pop-up parts)
• Ribbon controls
• OS dialogs
Project Options | Appearance
From this…
To this!
VCL Style Designer
Typical Usage
• Uses Vcl.Styles, Vcl.Themes;
• TStyleManager.SetStyle(‘Ruby Red Graphite’);

RTL
RTL
What’s new in the RTL?
• 64-bit for Windows!!!
• MacOSX - No COM, No ActiveX. :)
– Windows specifics has been mapped to MacOSX equivalents wherever
possible
• TOSVersion
– Architecture (32/64-bit), Platform (Win/Mac), Major, minor OS version, Service Pack info
• TFormatSettings
– replaces global format setting variables (that don't exist on MacOSX)
• TZipFile - cross platform Zip support
• SymLinks in IOUtils and SysUtils file handling routines
– class function TFile.CreateSymLink(const Link, Target: string): Boolean;
• TLoginCredentialService
– Extensible framework agnostic login credential services with support for
callbacks (success, failure, etc)
• TPoint, TRect, TSize - new methods and properties
• TPointF, TRectF, TSizeF - floating point versions
TFormatSettings (SysUtils)
type
TFormatSettings = record // System.SysUtils

CurrencyString: string;
CurrencyFormat: Byte;
CurrencyDecimals: Byte;
DateSeparator: Char;
TimeSeparator: Char;
ListSeparator: Char;
ShortDateFormat: string;
LongDateFormat: string;
TimeAMString: string;
TimePMString: string;
ShortTimeFormat: string;
LongTimeFormat: string;
ShortMonthNames: array[1..12] of string;
LongMonthNames: array[1..12] of string;
ShortDayNames: array[1..7] of string;
LongDayNames: array[1..7] of string;
ThousandSeparator: Char;
DecimalSeparator: Char;
TwoDigitYearCenturyWindow: Word;

end;
TZipFile (System.Zip)
type
TZipFile = class
..
public

procedure Open(ZipFileName: string; OpenMode: TZipMode); overload;
procedure Open(ZipFileStream: TStream; OpenMode: TZipMode); overload;
procedure Close;
procedure Extract(FileName: string; Path: string = ''; CreateSubdirs: Boolean=True); overload;
procedure Extract(Index: Integer; Path: string = ''; CreateSubdirs: Boolean=True); overload;
procedure ExtractAll(Path: string = '');
procedure Read(Index: Integer; out Bytes: TBytes); overload;
procedure Read(FileName: string; out Stream: TStream); overload;
procedure Read(Index: Integer; out Stream: TStream); overload;
procedure Add(FileName: string; ArchiveFileName: string = '';
Compression: TZipCompression = zcDeflate); overload;

property FileCount: Integer read GetFileCount;
property FileNames: TArray<string> read GetFileNames;

end;
TLoginCredentialService
type
TLoginCredentialService = class sealed
public const
Default = '';
DefaultUsrPw = 'DefaultUsrPw'; // do not localize
DefaultUsrPwDm = 'DefaultUsrPwDm'; //do not localize

strict private class var
FLoginHandlers: TStringList;
strict private
class constructor Create;
class destructor Destroy;
class function IndexOfHandler(const Context: TLoginCredentialEvent): Integer;
public
class procedure RegisterLoginHandler(const Context: string; const HandlerEvent: TLoginCredentialEvent); static;
class procedure UnregisterLoginHandler(const Context: string; const HandlerEvent: TLoginCredentialEvent); static;

class function GetLoginCredentialEvent(const Context: string): TLoginCredentialEvent; static;


class function GetLoginCredentials(const Context: string; Sender: TObject; const Callback: TLoginEvent): Boolean; overload; static;
class function GetLoginCredentials(const Context: string; const Callback: TLoginFunc): Boolean; overload; static;
class function GetLoginCredentials(const Context: string; var Username, Password: string): Boolean; overload; static;
class function GetLoginCredentials(const Context: string; var Username, Password, Domain: string): Boolean; overload; static;
end;
TPointF (System.Types)
type
TPointF = record
X: Single;
Y: Single;
public
constructor Create(const P: TPointF); overload;
constructor Create(const X, Y: Single); overload;
constructor Create(P: TPoint); overload;
class operator Equal(const Lhs, Rhs: TPointF): Boolean;
class operator NotEqual(const Lhs, Rhs: TPointF): Boolean;
class operator Add(const Lhs, Rhs: TPointF): TPointF;
class operator Subtract(const Lhs, Rhs: TPointF): TPointF;
function Distance(const P2: TPointF): Double;
procedure SetLocation(const X, Y: Single); overload;
procedure SetLocation(const P: TPointF); overload;
procedure SetLocation(const P: TPoint); overload;

function Add(const Point: TPointF): TPointF; overload;
function Add(const Point: TPoint): TPointF; overload;
function Subtract(const Point: TPointF): TPointF; overload;
function Subtract(const Point: TPoint): TPointF; overload;
function IsZero: Boolean;
function Ceiling: TPoint;
function Truncate: TPoint;
function Round: TPoint;
end;
C++
What’s New in C++?
• FireMonkey
• Live Bindings
• DataSnap
• Extended RTTI
• Audits and Metrics
Demos
Demos
• 32-bit/64-bit Stylish Fish Facts
• C++ Stylish Fish Facts
• Stylish Live Bindings Fish Facts
DataSnap and Cloud

Deep Dive
Agenda
• RAD Cloud Overview
• DBExpress
• New Cloud API
• What’s new in DataSnap
Cloud API
What is the Cloud API?

“Delphi API for accessing cloud application services


from Amazon and Microsoft Azure.”
Cloud API service support

Storage Azure Blobs Service Amazon S3


Table Azure Table Service SimpleDB
Queue Azure Queue Service Amazon SQS
Name conventions
• Amazon and Microsoft use different names for
the same things

Container = Bucket
Blobs = Object
Page = Multipart
ACL = ACL (Access Control List)
Microsoft Azure
• Blob Storage
– Unstructured storage
– Defined Container
– For storing large pieces of data such as: Images, Video,
Documents, etc.
• Azure Tables
– Scalable structured storage
– NOSQL type tables
– Entities stored in a table
– Different set of properties made up of different types
• Queues
– Persistent asynchronous messaging
– Each message is up to 8kb long
Amazon WS
• Simple Storage Service (S3)
– Blob Storage
– Unstructured storage
– Defined Container
– For storing large pieces of data such as: Images, Video, Documents,
etc.
• SimpleDB - Tables
– Scalable structured storage
– NOSQL type tables
– Entities stored in a table
– Different set of properties made up of different types
• Simple Queue Service (SQS)
– Persistent asynchronous messaging
– Each message is up to 64kb long
Deploying to the Cloud
• Deployment manager supports:
– Microsoft Azure
– Amazon EC2
What's new in DataSnap
What’s new in DataSnap
• Enhancements
– Server
– REST Interfaces
– Callback
– Authentication Manager
• New DataSnap Monitoring and Control
Server
• Proxy info support for DataSnap HTTP
connections in TSQLConnection and
TDSRESTConnection
• New TDBXChannelInfo.DBXClientInfo
(TDBXClientInfo record) provides:
– IP Address
– Protocol
– Application Name (when possible) – only for HTTP
HTTPS Support
• For Stand-alone DataSnap servers
• For Stand-alone WebBroker servers
• DataSnap Wizards updated with HTTPS
support
Session Manager
• Session support for TCP/IP protocol
• Support for store and retrieve TObject in
Sessions
• Sessions created and destroyed with the
TCP/IP protocol now notifies the
AddSessionEvent and RemoveSessionEvent
• Support for multiple Callback Tunnels on
DataSnap REST Interface
Callback Tunnel Manager
• TDSCallbackTunnelManager class in DSServer
unit
• Allows tracking when:
– Callback is added or removed
– Tunnel is created or closed
Callbacks
• Heavyweight callbacks now support
broadcasting to specific callbacks
• GetAllChannelNames added to the DSServer
to get the name of all callback channels
Callback client side events
• Notifications whenever the manager’s tunnel
is opened or closed, or when callbacks are
added to it or removed from it. Available for:
– Delphi DBX Client Events
– Delphi REST Client Events
– JavaScript REST Client Events
Delphi DBX Client Events
• TDSClientCallbackChannelManager
component, event OnChannelStateChange
• Method signature:
(Sender: TObject; const EventItem: TDSClientChannelEventItem);

• TunnelClosedByServer event type for


connections closed by the server or
connection loss.
Delphi REST Client Events
• TDSRestClientChannel component, event
OnChannelStateChange
• Method signature:
(Sender: TObject; const EventItem: TDSRESTChannelEventItem);

• ChannelClosedByServer event type for abrupt


connection loss with the server
JavaScript Client Events
• Set an event function to be invoked when changes happen
to the channel or one of its callbacks

var channel = new ClientChannel (clientID, channelName);


channel.onChannelStateChange = HandleChannelEvent;

• If the server gracefully closes the channel, then the client


gets an event type of
“ClientChannel .EVENT_CHANNEL_STOP”

• If the connection is abruptly lost, client will get an event


type of “ClientChannel. EVENT_SERVER_DISCONNECT”.
JavaScript session Support
• initSessionData function (in
serverFunctionExecutor.js) now optionally
takes a second parameter.
• The parameter will be prefixed to the general
cookie ID (dssessionid).
• Allows you to have complete control over
which application uses which session
ID/cookie.
JSON results and REST calls
• OnResult event has been added to the
TDSHTTPWebDispatcher and TDSHTTPService
components
• Allow to change the JSON result format in
REST calls.
• Method signature:
(Sender: TObject; var ResultVal: TJSONValue;
const Command: TDBXCommand; var Handled:
Boolean);
Query parameters in REST calls
• GetInvocationMetadata().QueryParams

• Returns a TStrings which holds a key value


pairs for all of the query parameters passed in
through the URL of the REST call
DataSnap Monitoring and
Control
DataSnap Monitoring and Control

“DataSnap servers in XE2 are able to easily


monitor connections, and close any TCP
connection they wish.”
What you can do
• Take control over the client connections
• Monitor client requests
• Limit the number of requests per connection
• Improve Security
• More…
How it works?
• TDSTCPServerTransport components has two
new events:
– onConnect
– onDisconnect
• Connections are linked with a Session ID
Listening to TCP/IP events
Detecting Graceless Disconnects
• By default, the OnDisconnect event will not be
notified if the client abruptly loses his internet
connection
• This behavior depends on OS configuration
• Use TDSTCPChannel methods to control this
behavior for each connection:
– EnableKeepAlive
– DisableKeepAlive
How to use EnableKeepAlive
• If the connection is idle for 10 seconds, then
send a keep-alive packet to check if the client
is still there.

Event.Channel.EnableKeepAlive(10000);
How to use EnableKeepAlive
• If the client doesn’t respond the OS will
resend the packet X number of times (Win 7
will retry 10 times).

• You can specify the number of milliseconds to


wait between retries if a client doesn't
respond to a packet.

Event.Channel.EnableKeepAlive(10000, 100);
KeepAlive Enablement
• Available through TDSTCPServerTransport
component
• Three new published properties
– KeepAliveEnablement - (Set: Default, Enabled,
Disabled)
– KeepAliveTime - Integer Milliseconds value
– KeepAliveInterval - Integer Milliseconds value
How to use DisableKeepAlive
• Get the associated Channel for the given
connection and call:
DisableKeepAlive;
Closing Client Connections
• Connection can be closed any time
• Channel provide the connection instance

//Get the associated Channel for the given connection, and if successful close it
if FConnections.TryGetValue(Connection, Channel) then
Channel.Close;
Demo
• Tracking all the TCP/IP connections and their
corresponding sessions
• How to manually close a TCP/IP connection
from the server
• How to detect when a client has lost internet
connectivity while connected.
Mobile and Connectors

Deep Dive
Mobile Connectors for DataSnap
• DataSnap Mobile Connectors
– iOS – Objective C
– Android – Java
– BlackBerry – Java
– Windows Phone 7 – C#, Prism
DataSnap Mobile Connectors Demonstration
RadPHP XE2 – Mobile App
RadPHP XE2 – Phone Gap
Tools | Wizard for PhoneGap
Summary
• FireMonkey - The Next Generation Business
Application Platform
• Fully harness the powerful GPU graphics hardware
• Rapidly build visually spectacular applications
• Invest in one platform and deploy to numerous OS-s
• Delphi and C++ compiled, native executable
• Fully programmable animations and effects

• Your imagination is the only limit !!!

• Go FIREMONKEY !!!
RAD Studio XE2
The ultimate application development suite for Windows, Mac, mobile and Web

• Deliver Fast Native Applications


on Windows, Mac, Web and Mobile
• Speed Up Your Development Process with RAD
• Create Visually Stunning and Interactive
Business Applications
• Build Applications that Connect Everywhere
• Break Free from Grids – Visualize Live Data

Potrebbero piacerti anche