Network Library with Websockets
Network Library with Websockets
Would be cool to have a network library which works with Websockets.
Re: Network Library with Websockets
I have to write my own because I can't wait.. It sucks..
to do it from the editor you have to basically wrap everything in functions with all the class and callback stuff escaped, then set states with the callbacks which you monitor with timers. A lot of time wasted..
to do it from the editor you have to basically wrap everything in functions with all the class and callback stuff escaped, then set states with the callbacks which you monitor with timers. A lot of time wasted..
Re: Network Library with Websockets
Any news on WEBSOCKETS ?
does anyone have it implemented already ?
(like http://www.purebasic.fr/english/viewtop ... =Websocket)
does anyone have it implemented already ?
(like http://www.purebasic.fr/english/viewtop ... =Websocket)
Re: Network Library with Websockets
Perhaps this is a starting point for you:
Greetings ... Peter
Code: Select all
Procedure doSend(message.s)
Debug "Sending: " + message
! websocket.send(v_message);
Debug "-------"
EndProcedure
Procedure onOpen(evt)
Debug "onOpen()"
; Debug evt
Debug "-------"
doSend("WebSocket rocks")
EndProcedure
Procedure onClose(evt)
Debug "onClose"
; Debug evt
Debug "-------"
EndProcedure
Procedure onMessage(evt)
Debug "onMessage()"
Protected MessageFromWs.s
! v_messagefromws = v_evt.data;
Debug "MessageFromWs: " + MessageFromWs
Debug "-------"
! websocket.close();
EndProcedure
Procedure onError(evt)
Debug "onError()"
; Debug evt
Debug "-------"
EndProcedure
Procedure Dummy()
onOpen(0)
onClose(0)
onMessage(0)
onError(0)
EndProcedure
Procedure initWebSocket(wsUri.s)
! websocket = new WebSocket(v_wsuri);
! websocket.onopen = function(evt) { f_onopen(evt) };
! websocket.onclose = function(evt) { f_onclose(evt) };
! websocket.onmessage = function(evt) { f_onmessage(evt) };
! websocket.onerror = function(evt) { f_onerror(evt) };
EndProcedure
initWebSocket("ws://echo.websocket.org/")
Re: Network Library with Websockets
Thanks Peter, very useful code. 

Re: Network Library with Websockets
I'm currently working on modules on github. I'll be creating a module for WebSockets too.
It's not yet ready but it can be found here once it is: https://github.com/sworteu/XJS
It's not yet ready but it can be found here once it is: https://github.com/sworteu/XJS
- SinisterSoft
- Posts: 77
- Joined: Sun Apr 06, 2014 11:41 pm
- Location: Preston, UK
- Contact:
Re: Network Library with Websockets
@sworteu Great modules, thanks for sharing. Local and session storage should be 'built-in' imho, so @fred should take a look at your code...
Re: Network Library with Websockets
They are not yet completed. Code may be build-in but that's up to fred.SinisterSoft wrote:@sworteu Great modules, thanks for sharing. Local and session storage should be 'built-in' imho, so @fred should take a look at your code...
I'd make spiderbasic same as purebasic if i where fred.
Re: Network Library with Websockets
Just to add: use wss:// for HTTPS/TLS enabled domains and only when the certificate is signed by a CA. Modern browsers need modified to support self-signed or revoked certificates anywhere including websocket implementations.
I'd imagine Fred&Team will add this at some point considering most browser stuff uses push type notifications(server sends to clients instead of clients polling/timed-requesting and stressing the server) these days and most web hosts don't support long-polling HTTP connections even if over ajax.
I'd imagine Fred&Team will add this at some point considering most browser stuff uses push type notifications(server sends to clients instead of clients polling/timed-requesting and stressing the server) these days and most web hosts don't support long-polling HTTP connections even if over ajax.
Re: Network Library with Websockets
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?
Only thing missing for me is websocket support.
Anyone has allready done a module for binary websockets?