#51 2015-05-29 20:05:53

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: implement push notifications

The closed is perhaps the TSQLRestClientURI.UpdateFromServer() method.
See http://synopse.info/files/html/Synopse% … #TITLE_267

At table level, you could define http://synopse.info/files/html/Synopse% … l#TITL_147
There are callbacks which could be triggered on the client side for each modification.

Offline

#52 2015-06-06 23:14:18

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Re: implement push notifications

ab wrote:

Try with the latest version.

Also check if the callback has not been released on the client side.
See also the CallbackReleased() kind of method (defined e.g. in IServiceWithCallbackReleased). It would allow the server to be notified when a callback has been released on the client server side, to avoid such errors.

Please considers this scenario: there is a server application and a client application. After run server application, you run client application. Now for same reason the client application is terminate with a "no standard mode", for example the application process is terminate from task manager. Now client is run again.

I think in this case the there are problem with callback in fact I get a error like my last image posted on this thread.

Is it right or something wrong?

Offline

#53 2015-06-07 06:55:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: implement push notifications

This is why you should better protect the callback execution, e.g.:

  for i := FCallbacks.Count-1 downto 0 do
    try
      FCallback[i].NotifyWithMethod(client);
    except
      FCallbacks.Delete(i); // safer to unsubscribe ASAP
    end;

The try ... except block will unsubscribe the callback if there is any notification problem.

Note that here we define a TDynArray to easily handle a dynamic array of events, but you may have used InterfaceArrayDelete().

Also note that we use a "downto 0" loop, since the deletion may happen during the loop process, so it should be made downwards.

Offline

#54 2015-07-31 13:58:09

ulutepe
Member
Registered: 2014-05-23
Posts: 6

Re: implement push notifications

i thing mormot needs more examples about using interface based websocket services with callbacks and sending binary data's

Offline

#55 2015-08-01 10:00:27

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: implement push notifications

I'm using those in production now, with several server nodes communicating via websockets in a private cloud.
But the code can't be shared!
smile

Once it would be stabilized, I would probably write a dedicated DDD sample.
There is still a lot of features coming on - e.g. we introduced nodes remote live monitoring.
Interface-based services with callbacks is pretty powerful, and easy to work with.

Offline

#56 2015-08-01 13:05:28

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 332

Re: implement push notifications

A sample project to small scale with those features would be great.


Esteban

Offline

#57 2015-09-18 22:59:52

warleyalex
Member
From: Sete Lagoas-MG, Brasil
Registered: 2013-01-20
Posts: 250

Re: implement push notifications

In my experiments, when I send a video .mp4 from a server to multi browser, the socket connection works just fine, here is my Multi Browser Video Sync with mORMot and Websocket
https://youtu.be/CB1LFDvwn7o

I can sync videos for instance, but I have wait to load completely the media resource blob to play the video, which does not have proper content/type, a resource is transferred with MIME type text/plain.
-----
blob:null/b20b85d2-eb76-451f-96b4-291e7d229085
Type: data
Length: 2,416,975
Uuid: 969adfff-b93c-4475-bf97-f7910059d5df
----

I think we can to boost the performance by sending the correct content-type.

a) Is there any way to set at server side, the content-type "video/mp4", when I send binary?
I know at server-side we have GetMimeContentTypeHeader to get the content-type from client side.

b) As I said, the video plays fine, but it always waits until it's downloaded the entire video, before playing, resulting in a large delay, I'd love if is it possible video streaming over websockets, for instance, send streams small enough to load quickly.

c) Can you confirm that deflate frame compression is totally disabled or not implemented (does not compress exchanged data)?

for instance, when I send a text message "warleyalex abcd" the handshake is something:

GET /whatever/ HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: localhost:8888
Origin: null
Sec-WebSocket-Protocol: galo
Pragma: no-cache
Cache-Control: no-cache
Sec-WebSocket-Key: uJ49CnrXsMjestj7+EIK8A==
Sec-WebSocket-Version: 13
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits, x-webkit-deflate-frame
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Protocol: galo
Sec-WebSocket-Accept: c6dYbZsy+aWbvoH9QFRYCsYSS1g=

Content
Ã¨ú–´Éˆú¦Ñ›ú¦ÐÚ÷¡Ëž.warleyalex abcd


I have edited SynBidirSock, to add extra header

  ClientSock.SockSend(['HTTP/1.1 101 Switching Protocols'#13#10+
    'Upgrade: websocket'#13#10'Connection: Upgrade'#13#10+
    'Sec-WebSocket-Protocol: ',prot.Name,#13#10+
    'Sec-WebSocket-Accept: ',BinToBase64(@Digest,sizeof(Digest)),#13#10+'Sec-WebSocket-Extensions: x-webkit-deflate-frame',#13#10]);


it would expect, something like this, but server disconnect after I send a msg.

...
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Protocol: galo
Sec-WebSocket-Accept: q+eFL6AQUFb8/UXSiLIR8X74UzU=
Sec-WebSocket-Extensions: x-webkit-deflate-frame

Content
Á?ýik.²E¡vP=#ó´Äk?
*O,ÊI­THÌI­..

Could not decode a text frame as UTF-8.
*O,ÊI­THÌI­
and browser is disconnected.

Offline

#58 2015-09-19 10:18:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: implement push notifications

So you implemented you own websocket protocol, names "galo"?
I do not understand your point.
AFAIK there is no "content-type" in WebSockets by itself.
All depends on the protocol used within WebSockets.
So it is all on your hands, not mORMot's.

Offline

#59 2015-09-19 12:28:19

warleyalex
Member
From: Sete Lagoas-MG, Brasil
Registered: 2013-01-20
Posts: 250

Re: implement push notifications

I'd like to compress exchanged data packets, but it seems that deflate frame compression is totally disabled? I can see uncompressed content packets when I send a text.

following project Project31SimpleEchoServer, for instance, mORMot omit Sec-WebSocket-Extensions:x-webkit-deflate-frame from the Response Header.

If I edit SynBidirSock, to append this extra header, I can see compressed exchanged data packets, but
terminates the connection:
onerror - code:undefined, reason:undefined, wasClean:undefined, status:1
onclose - code:1006, reason:, wasClean:false, status:3

I'm pretty sure my chrome support that extension.

Offline

#60 2015-09-19 14:16:32

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: implement push notifications

You do not need to edit SynBidirSock.
You can create your own protocol, using a sub-class.

In practice, mORMot ignore Sec-WebSocket-Extensions because it use its own protocol.
If you use pure mORMot client/servers, it will use e.g. TWebSocketProtocolBinary, identified as 'synopsebinary' application content, which support encryption and compression.

AFAIK WebSockets extensions, especially compression, are still experimental and evolving features.
See e.g. this draft RFC: https://tools.ietf.org/html/draft-ietf- … ression-28
Once there would be some stable extension, we may support one for Cross-Platform AJAX targets.

Offline

Board footer

Powered by FluxBB