EventHandler
hololinked.server.http.handlers.EventHandler
Bases: BaseHandler
handles events emitted by Thing and tunnels them as HTTP SSE.
Source code in repo/hololinked/hololinked/server/http/handlers.py
700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 | |
Attributes
resource
instance-attribute
an event, or the observable property whose change event is streamed - both name an event to subscribe to
Functions
initialize
initialize(resource: InteractionAffordance | EventAffordance, config: RuntimeConfig, logger: BoundLogger, thing: Thing, metadata: HandlerMetadata | None = None) -> None
Set up the handler to stream events with a plain SSE data header.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the |
Source code in repo/hololinked/hololinked/server/http/handlers.py
set_custom_default_headers
Sets default headers for event handling. The general headers are listed as follows:
Content-Type: text/event-stream
Cache-Control: no-cache
Connection: keep-alive
Access-Control-Allow-Credentials: true # Possibly for cookie auth
Access-Control-Allow-Origin: <client> # if CORS is enabled
Source code in repo/hololinked/hololinked/server/http/handlers.py
get
async
Events are support only with GET method.
options
async
Options for the resource.
Source code in repo/hololinked/hololinked/server/http/handlers.py
handle_datastream
async
Called by GET method and handles the event publishing.
Source code in repo/hololinked/hololinked/server/http/handlers.py
JPEGImageEventHandler
Bases: EventHandler
handles events with images with JPEG image data header.
Source code in repo/hololinked/hololinked/server/http/handlers.py
Functions
initialize
initialize(resource: InteractionAffordance | EventAffordance, config: RuntimeConfig, logger: BoundLogger, thing: Thing, metadata: HandlerMetadata | None = None) -> None
Set up the handler to stream events with a base64 JPEG image SSE data header.
Source code in repo/hololinked/hololinked/server/http/handlers.py
PNGImageEventHandler
Bases: EventHandler
handles events with images with PNG image data header.
Source code in repo/hololinked/hololinked/server/http/handlers.py
Functions
initialize
initialize(resource: InteractionAffordance | EventAffordance, config: RuntimeConfig, logger: BoundLogger, thing: Thing, metadata: HandlerMetadata | None = None) -> None
Set up the handler to stream events with a base64 PNG image SSE data header.