Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | {1401} introduced TWebSocketProcessSettings.OnClientConnected and OnClientDisconnected events |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e2e8eb68efe554fa0bcce0fd399f53ec |
User & Date: | ab 2015-05-26 06:20:57 |
2015-05-26
| ||
09:25 | {1402} refactored TSQLRestServerURIContext.URIDecodeREST to allow '/' char in the URI parameters check-in: b0b91e631d user: ab tags: trunk | |
06:20 | {1401} introduced TWebSocketProcessSettings.OnClientConnected and OnClientDisconnected events check-in: e2e8eb68ef user: ab tags: trunk | |
2015-05-24
| ||
13:54 | {1400} added the new TDocVariantData.ToArrayOfConst overloaded functions, which are able to be passed e.g. as FormatUTF8() parameter check-in: d3f44776ea user: ab tags: trunk | |
Changes to SynBidirSock.pas.
374 375 376 377 378 379 380 381 382 383 384 385 386 387 ... 441 442 443 444 445 446 447 448 449 450 451 452 453 454 ... 698 699 700 701 702 703 704 705 706 707 708 709 710 711 .... 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 .... 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 |
// the connection before failing // - defaut is 5000, i.e. 5 seconds CallbackAcquireTimeOutMS: cardinal; /// how many milliseconds the callback notification should wait for the // client to return its answer // - defaut is 30000, i.e. 30 seconds CallbackAnswerTimeOutMS: cardinal; /// by default, contains [] to minimize the logged information // - set logHeartbeat if you want the ping/pong frames to be logged // - set logTextFrameContent if you want the text frame content to be logged // - used only if WebSocketLog global variable is set to a TSynLog class LogDetails: set of (logHeartbeat,logTextFrameContent); /// will set the default values procedure SetDefaults; ................................................................................ // - the request may be sent in blocking or non blocking mode // - returns the HTML status code (HTML_SUCCESS=200 for success) function NotifyCallback(aRequest: THttpServerRequest; aMode: TWebSocketProcessNotifyCallback): cardinal; virtual; /// the settings currently used during the WebSockets process // - defined as a pointer so that you may be able to change the values function Settings: PWebSocketProcessSettings; {$ifdef HASINLINE}inline;{$endif} published /// the Sec-WebSocket-Protocol application protocol currently involved // - TWebSocketProtocolJSON or TWebSocketProtocolBinary in the mORMot context // - could be nil if the connection is in standard HTTP/1.1 mode property Protocol: TWebSocketProtocol read fProtocol; end; ................................................................................ begin HeartbeatDelay := 0; LoopDelay := 500; DisconnectAfterInvalidHeartbeatCount := 5; CallbackAcquireTimeOutMS := 5000; CallbackAnswerTimeOutMS := 5000; LogDetails := []; end; procedure TWebSocketProcessSettings.SetFullLog; begin LogDetails := [logHeartbeat,logTextFrameContent]; end; ................................................................................ except result := false; end; end; procedure TWebSocketProcess.ProcessStart; begin SetLastPingTicks; end; procedure TWebSocketProcess.ProcessStop; begin // nothing to do at this level end; function TWebSocketProcess.SendFrame( const Frame: TWebSocketFrame): boolean; var hdr: TFrameHeader; len: cardinal; begin ................................................................................ (fOwnerThread as TWebSocketServerResp).fServer,fOwnerConnection,fOwnerThread); RequestProcess := TWebSocketServerResp(fOwnerThread).fServer.Request; end; procedure TWebSocketProcessServer.ProcessStart; var frame: TWebSocketFrame; begin // notify e.g. TOnWebSocketProtocolChatIncomingFrame inherited; frame.opcode := focContinuation; fProtocol.ProcessIncomingFrame(self,frame,''); end; procedure TWebSocketProcessServer.ProcessStop; var frame: TWebSocketFrame; begin // notify e.g. TOnWebSocketProtocolChatIncomingFrame frame.opcode := focConnectionClose; fProtocol.ProcessIncomingFrame(self,frame,''); inherited; end; { -------------- WebSockets Client classes for bidirectional remote access } { THttpClientWebSockets } |
> > > > > > > > > > > > > > > > > > | > > > > > | | |
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 ... 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 ... 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 .... 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 .... 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 |
// the connection before failing // - defaut is 5000, i.e. 5 seconds CallbackAcquireTimeOutMS: cardinal; /// how many milliseconds the callback notification should wait for the // client to return its answer // - defaut is 30000, i.e. 30 seconds CallbackAnswerTimeOutMS: cardinal; /// callback run when a WebSockets client is just connected // - triggerred by TWebSocketProcess.ProcessStart OnClientConnected: TNotifyEvent; /// callback run when a WebSockets client is just disconnected // - triggerred by TWebSocketProcess.ProcessStop OnClientDisconnected: TNotifyEvent; /// by default, contains [] to minimize the logged information // - set logHeartbeat if you want the ping/pong frames to be logged // - set logTextFrameContent if you want the text frame content to be logged // - used only if WebSocketLog global variable is set to a TSynLog class LogDetails: set of (logHeartbeat,logTextFrameContent); /// will set the default values procedure SetDefaults; ................................................................................ // - the request may be sent in blocking or non blocking mode // - returns the HTML status code (HTML_SUCCESS=200 for success) function NotifyCallback(aRequest: THttpServerRequest; aMode: TWebSocketProcessNotifyCallback): cardinal; virtual; /// the settings currently used during the WebSockets process // - defined as a pointer so that you may be able to change the values function Settings: PWebSocketProcessSettings; {$ifdef HASINLINE}inline;{$endif} /// the associated communication socket // - on the server side, is a THttpServerSocket property Socket: TCrtSocket read fSocket; /// how many frames have been processed by this connection property ProcessCount: integer read fProcessCount; published /// the Sec-WebSocket-Protocol application protocol currently involved // - TWebSocketProtocolJSON or TWebSocketProtocolBinary in the mORMot context // - could be nil if the connection is in standard HTTP/1.1 mode property Protocol: TWebSocketProtocol read fProtocol; end; ................................................................................ begin HeartbeatDelay := 0; LoopDelay := 500; DisconnectAfterInvalidHeartbeatCount := 5; CallbackAcquireTimeOutMS := 5000; CallbackAnswerTimeOutMS := 5000; LogDetails := []; OnClientConnected := nil; OnClientDisconnected := nil; end; procedure TWebSocketProcessSettings.SetFullLog; begin LogDetails := [logHeartbeat,logTextFrameContent]; end; ................................................................................ except result := false; end; end; procedure TWebSocketProcess.ProcessStart; begin if Assigned(fSettings.OnClientConnected) then try fSettings.OnClientConnected(Self); except end; SetLastPingTicks; end; procedure TWebSocketProcess.ProcessStop; begin if Assigned(fSettings.OnClientDisconnected) then try fSettings.OnClientDisconnected(Self); except end; end; function TWebSocketProcess.SendFrame( const Frame: TWebSocketFrame): boolean; var hdr: TFrameHeader; len: cardinal; begin ................................................................................ (fOwnerThread as TWebSocketServerResp).fServer,fOwnerConnection,fOwnerThread); RequestProcess := TWebSocketServerResp(fOwnerThread).fServer.Request; end; procedure TWebSocketProcessServer.ProcessStart; var frame: TWebSocketFrame; begin // notify e.g. TOnWebSocketProtocolChatIncomingFrame inherited ProcessStart; frame.opcode := focContinuation; fProtocol.ProcessIncomingFrame(self,frame,''); end; procedure TWebSocketProcessServer.ProcessStop; var frame: TWebSocketFrame; begin // notify e.g. TOnWebSocketProtocolChatIncomingFrame frame.opcode := focConnectionClose; fProtocol.ProcessIncomingFrame(self,frame,''); inherited ProcessStop; end; { -------------- WebSockets Client classes for bidirectional remote access } { THttpClientWebSockets } |
Changes to SynCommons.pas.
11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 |
procedure ToRawUTF8DynArray(out Result: TRawUTF8DynArray); overload; /// save a document as an array of UTF-8 encoded JSON // - will expect the document to be a dvArray - otherwise, will raise a // EDocVariant exception // - will use VariantToUTF8() to populate the result array: as a consequence, // any nested custom variant types (e.g. TDocVariant) will be stored as JSON function ToRawUTF8DynArray: TRawUTF8DynArray; overload; /// save an array document as an array of TVarRec, i.e. an array of const // - will expect the document to be a dvArray - otherwise, will raise a // EDocVariant exception // - would allow to write code as such: // ! Doc.InitArray(['one',2,3]); // ! Doc.ToArrayOfConst(vr); // ! s := FormatUTF8('[%,%,%]',vr,[],true); |
> |
11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 |
procedure ToRawUTF8DynArray(out Result: TRawUTF8DynArray); overload;
/// save a document as an array of UTF-8 encoded JSON
// - will expect the document to be a dvArray - otherwise, will raise a
// EDocVariant exception
// - will use VariantToUTF8() to populate the result array: as a consequence,
// any nested custom variant types (e.g. TDocVariant) will be stored as JSON
function ToRawUTF8DynArray: TRawUTF8DynArray; overload;
{$ifdef HASINLINE}inline;{$endif}
/// save an array document as an array of TVarRec, i.e. an array of const
// - will expect the document to be a dvArray - otherwise, will raise a
// EDocVariant exception
// - would allow to write code as such:
// ! Doc.InitArray(['one',2,3]);
// ! Doc.ToArrayOfConst(vr);
// ! s := FormatUTF8('[%,%,%]',vr,[],true);
|
Changes to SynopseCommit.inc.
1 |
'1.18.1400'
|
| |
1 |
'1.18.1401'
|