Defines the cw.transfer library, which sends messages that are too large for a single net message.

A net message holds 64 KB, which is all that cable.send has. cw.transfer:Send takes the same arguments, encodes them with SFS and sends the result in chunks over the cwTransfer Cable message; the other side puts the chunks back together and calls the function given to cw.transfer:Receive. That function is registered with cable.receive as well, so one receiver gets the message whichever way it was sent.

A receiver buffers one unfinished transfer per sender and nothing for names without a receiver. A transfer is dropped when its sender starts another, sends a chunk out of order, sends more than the size limit or disconnects.

Summary

Methods

Sets the function that receives a message, whether it is sent with cw.transfer:Send or with cable.send.
Sends a message of any size to one, several or all players.

Methods

cw.transfer:Receive(name, Callback)

shared gamemodes/catwork/gamemode/core/libraries/sh_transfer.lua:44

Sets the function that receives a message, whether it is sent with cw.transfer:Send or with cable.send.

cw.transfer:Receive('ViewNotepad', function(entity, uniqueID, text)
  -- ...
end)

Parameters

  • name String Name of the message
  • Callback Function Called with the sent values; on the server the sending Player comes first

See also

cw.transfer:Send(target, name, ...)

shared gamemodes/catwork/gamemode/core/libraries/sh_transfer.lua:90

On the server

Sends a message of any size to one, several or all players.

The message arrives at the function the client gave to cw.transfer:Receive; a name that only has a cable.receive receiver is ignored by the client. An error is raised when the values cannot be encoded (functions, userdata) or the encoded data is larger than 8 MB.

cw.transfer:Send(player, 'ViewNotepad', entity, entity.uniqueID, entity.text)

Parameters

  • target Player A player or a list of players; nil sends the message to everyone
  • name String Name of the message
  • ... Any The values to send, as for cable.send

See also

On the client

Sends a message of any size to the server.

The message arrives at the function the server gave to cw.transfer:Receive; a name that only has a cable.receive receiver is ignored by the server. An error is raised when the values cannot be encoded (functions, userdata) or the encoded data is larger than 512 KB, which is all the server accepts.

cw.transfer:Send('EditNotepad', entity, text)

Parameters

  • name String Name of the message
  • ... Any The values to send, as for cable.send

See also

Defined in

Defined in