fsprojects / IfSharp

F# for Jupyter Notebooks
Other
440 stars 71 forks source link

COMM messages support #182

Closed dgrechka closed 5 years ago

dgrechka commented 6 years ago

This added the support for comms. This can be considered as a part of #126 and #137 as Jupyter widgets are based on comms.

The comm identified by target_name now can be registered through specifying a set of callbacks.

E.g. in App.fs we can do the following

Kernel.Value.RegisterComm("echo-comm",
                (fun send data -> ()), // comm onOpen callback
                (fun send message -> // comm onMessage callback
                       send message.data), // here it sends received data back to the Frontend
                (fun data -> ())) // comm onClose callback

The code in PR creates and destroys comm instances according to the Jupyter client protocol. Maintains the opened comms, processes the comm messages through the callback which is specified during comm registration.

The code also logs the comm operations with logMessage (now dumped to shell.log). If it is not desired I'll update the pull request.

cgravill commented 5 years ago

Looks good, given it's a major protocol update it needs some reasonable testing coverage. Have you tried it on both Windows and Linux?

cgravill commented 5 years ago

I ran some checks and it all seems OK. I now suspect I misunderstood, this is the infrastructure support required for the future protocol switch. I'll go ahead and merge the pull request. Really looking forward to getting this feature going and the features it enables.