I just do UTF-8 JSON with this. I'd like to have cleaner code by having a native library though. I do push out to clients based on which room or table they are at when a distributed event happens. Polling with http requests would choke a server and besides my server isn't same-origin. It's on a dedicated box with a dedicated IP.Thorium wrote:Now that SB supports memory operations i am reevaluating if it fits a project i plan to start soon.
Only thing missing for me is websocket support.
Anyone has allready done a module for binary websockets?
Network Library with Websockets
Re: Network Library with Websockets
Re: Network Library with Websockets
I didn't looked much to websockets, how do you see the SpiderBasic API for it ? Which features would be needed ?
Re: Network Library with Websockets
It's much like TCP sockets for networking. We would need a network library like PureBasics. One of the differences to normal TCP sockets is that it starts out as a http connection, which is then upgraded to a websockets connection with a handshake.Fred wrote:I didn't looked much to websockets, how do you see the SpiderBasic API for it ? Which features would be needed ?
Another difference is that data is transfered as a so called frame. A frame can be in binary format or in text format. It's much like a packet on normal TCP sockets.
So we need PureBasics network library in SpiderBasic with the added feature of distinguishing between binary data and text data.
Additionaly a websockets server for PureBasics network library would be very handy. Here is a lib that supports TLS: https://libwebsockets.org/index.html
There are allready websockets server examples on the PureBasic forums but non supports TLS, which is very important today.
Re: Network Library with Websockets
Rough idea:
I made this in minutes so I may have missed something.
Code: Select all
integer=CreateNetworkConnection(URL string);don't worry about ws or wss just return false if invalid cert or connection fail
bool=CloseNetworkConnection(Connection integer)
bool=GetNetworkData(Connection integer,CallBack function);callback as parameter
bool=SendNetworkString(Connection integer,String string)
Let user encode binary with Asc and Chr. Spec allows Array, Blob, and String to be exchanged with send() but string-only keeps with the theme of SB
Re: Network Library with Websockets
SB now has memory commands, so the theme is not strings only.tj1010 wrote: Let user encode binary with Asc and Chr. Spec allows Array, Blob, and String to be exchanged with send() but string-only keeps with the theme of SB
Encoding them with Asc and Chr would be terrible. Base64 should be used to encode binary data into a string. However i dont see why we would not want binary data.
The web was text based way to long and is heading in a binary direction.
Re: Network Library with Websockets
This socket code and the official http request function need to be tested on android and ios. Maybe they don't have same-origin policy. Else SB team will need to do ios&android sockets or at least HTTP POST support. The problem with GET only is most servers have tight limits on GET buffer size.