![]() For those of you who have read my previous blog entries may. As you can see from the code below I have taken advantage of mixing both Windows API with PureBasic API's to achieve the results. If you need to do so, make a copy of the memory in here. Most of the magic is done by Windows API ExtractIconEx function and from there we simply manipulate the icon images to display them in a gadget list window. !!!! Don't use the Payload after you return from this callback. *Event_Frame\Payload contains the data, *Event_Frame\Payload_Size is the size of the data in bytes Procedure WebSocket_Event(*Server, *Client, Event, *Event_Frame.WebSocket_Server::Event_Frame) If you need to do so, make a copy of the memory in here. *Event_Frame\Payload contains the data, *Event_Frame\Payload_Size is the size of the data in bytes. CloseHelp OpenHelp CatchImage CopyImage CreateImage FreeImage GrabImage ImageDepth ImageHeight ImageID ImageOutput. PrintN(" Text received: " PeekS(*Event_Frame\Payload, *Event_Frame\Payload_Size, #PB_UTF8|#PB_ByteLength)) # You only need to care about text and binary frames. If the filename does not include a full path, it is interpreted relative to the current directory. ImageGadget () for displaying image on an application window. SaveImage () Saves the specified image to disk. DrawImage () with ImageID () to draw the image on actual output channel. GrabImage () to create another image from a given area of the actual one. # It's either Text, Binary-Data, Ping-Frames or other stuff. CopyImage () to create another image from the actual one. # OpCode is the type of frame you receive. PrintN(" # Frame received from " *Client) !!!! From the moment you receive this event *Client must not be used anymore !!!! PrintN(" # Client disconnected: " *Client) PrintN(" # Client connected: " *Client) Procedure WebSocket_Event(*Server, *Client, Event, *Event_Frame.WebSocket_Server::Event_Frame) no need to worry about mutexes as this call is coming from your main loop The easier (but slower) method of using this WebSocket server is to poll for events.Įven though the server uses threads internally, you don't have to worry about race conditions, deadlocks and so on.Īll you need to do is to call WebSocket_Server::Event_Callback(*Server, *Callback) from your own main loop, this will call your event handling function that you have passed as the *callback parameter in the same context as your main loop. ![]() If you need to supply static files (html, js), this is the preferred way anyways. Best is to use a webserver (like Caddy) and setup a reverse proxy to the WebSocket server. Automatic splitting of frames into fragments, but this can be done by the application if needed.This will not hurt compatibility, as compression is optional. Passes nearly all of Autobahn|Testsuite test cases (289 / 303).Built in handling of control frames (ping, disconnect).The module combines fragment frames automatically, this is on by default and can be turned off in case the application needs to handle fragmentation itself.Callback based for easy use and low latency. ![]()
0 Comments
Leave a Reply. |