datastream.StreamToServer

From GMod Wiki

Jump to: navigation, search
Function
Syntax datastream.StreamToServer( String handler, Table :Var data, Function callback[, Function accept_callback] )
Where is this used?
Description:
Sends a datastream to the server. The server must allow you to send the stream. Accept callback is called whenever the server accepts or denies your stream. Callback is called when the operation is complete.
Returns: Number tempid
Part of Library: datastream
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Datastream.StreamToServer]Datastream.StreamToServer [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionSends the IncomingHook datastream with a table to the server.
Used onNewerClient.png
Code
datastream.StreamToServer( "IncomingHook", { "I dunno lol", 1, -1, 1.024, true, false, { "moar table?" } } );
OutputN/A
DescriptionSends the data to the server with callback.
Used onNewerClient.png
Code
 
local function Done( )
 
            print( "Done sending." );
 
end
datastream.StreamToServer( "IncomingHook", { "I dunno lol", 1, -1, 1.024, true, false, { "moar table?" } }, Done );
OutputDone sending.
DescriptionSends the data to the server with callback and saying whether or not our stream was accepted.
Used onNewerClient.png
Code
 
local function Done( )
 
            print( "Done sending." );
 
end
local function Accepted( accepted, tempid, id )
 
            if accepted then
                        print( "Temporary stream " .. tempid .. " was accepted! It's official ID is now " .. id );
            else
                        print( "Temporary stream " .. tempid .. " was denied." );
            end
 
end
 
local tempid = datastream.StreamToServer( "IncomingHook", { "I dunno lol", 1, -1, 1.024, true, false, { "moar table?" } }, Done, Accepted );
print( "Sent an operation. Our assigned tempid is " .. tempid );
OutputVaries.

Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox