(Web)sockets
tracked
B
Big Blep
As a high-performant and modern alternative to the
llHTTPRequest
and llRequestURL
, (web)sockets would be a great addition. It will allow objects and HUD elements to have direct bi-directional communication with back-end server software. The same can
be achieved with the existing HTTP methods, but it requires a lot of effort to implement.The (web)sockets would have to be proxied through the Linden Labs servers just like the HTTP requests to avoid the leaking of IP addresses. If websockets are to be used, the benefit of HTTPS certificates exist for a secure connection.
I am not requesting (web)sockets in the script to act as a server like
llRequestURL
, but for the script to always be the client to an external server (though feel free to implement that as well!).The functions could look like:
key llSocketOpen( string url /*, Other options... */ );
llSocketSend( key id, string data );
// llSocketSend does not need a 'key' to return; packets identify themselves
llSocketClose( key id );
The events could look like:
socket_receive( key id, string body ) {}
socket_close( key id, integer code ) {}
// Code would follow the standard, but code '0' could be "closed by own script".
There could be events for when the socket is opened or errors, too. In that case the
llSocketOpen
function can be non-blocking.Example code:
key handler;
default
{
state_entry() {
handler = llSocketOpen( "wss://example.com:8081" );
llSocketSend( handler, "Hello world!" );
}
socket_receive( key id, string body ) {
if( id == handler ) {
llSocketClose( id );
}
}
socket_close( key id, int code ) {
if( id == handler ) {
if( code == 0 ) {
llSay( 0, "The socket was closed by us!" );
} elseif( code > 0 && code <= 99 ) {
llSay( 0, "The socket was closed by the Linden proxy with code: "+ (string)code );
} else {
llSay( 0, "the socket was closed by the remote server with code: "+ (string)code );
}
}
}
}
Log In
Peter Stindberg
SL Feedback
tracked
SL Feedback
Hello, and thank you for your detailed feature request regarding the implementation of (web)sockets in Second Life. This idea has been brought up in the past and is currently tracked. We understand the potential benefits of having a more modern and efficient communication method for scripts, and we appreciate the effort you put into outlining the possible functions and events. While we have no estimate on when this might be implemented, please keep an eye on future updates. Your input is invaluable, and we hope you continue to share your ideas to help improve Second Life. Thank you!