CAOS-Programmierung: Befehlsgruppen: Net

Aus Wikibooks

Net

NET: ERRA (integer)

Returns an error code from the last command. Currently NET: LINE is the only command to set it.
Error codes are:
0 - Unknown
1 - Connection OK
2 - Connection failed, you or the server are offline
3 - Connection failed, invalid user name/password
4 - Connection failed, you are already logged in elsewhere
5 - Connection failed, too many users for server
6 - Connection failed, internal error
7 - Connection failed, new client version required.
Try NET: RAWE for more detailed diagnostic codes.

NET: EXPO (integer) chunk_type (string) dest_user_id (string)

Transwarp the target creature to the given user. The Creature is exported to the warp out directory; this command is very similar to PRAY EXPO. 
Return  value is one of the following:
0 for success
1 if the creature, or if pregnant any of its offspring, are already on disk in some form. This case won't happen much, if you use a special chunk 
name  like WARP.
2 if the user hasn't been online in this world yet / since the user name changed, so we don't know who they are.
When receiving a creature, use NET: FROM to find out who sent it.

NET: FROM (string) resource_name (string)

The user who sent the PRAY file which contains the specified resource. If the resource did not arrive as a message over the network via NET: MAKE or 
NET: EXPO, then this returns an empty string. The user returned by this command is guaranteed in a way that looking at the content of the PRAY file 
would not be. For example, the "Last Network User" attribute in an exported Creature made with NET: EXPO could be faked.

NET: HEAD (command)

Dump debugging informatino about who is NET: HEARing on what channels.

NET: HEAR (command) channel (string)

The target agent will now accept CAOS messages over the network on the specified channel, and execute their script as appropriate. Use NET: WRIT to 
send the message.

NET: HOST (string)

Returns the hostname, port, id and friendly name on that host that we are currently connected to, or empty string if offline. The fields are space 
separated, although the last field (friendly name) may contain spaces.

NET: LINE (command) state (integer)

Goes on or offline, connecting or disconnecting from the Babel server. Set to 1 to connect, 0 to disconnect. A NET: USER must be set first. NET: ERRA 
is set to any error code. While the connection is being made, this command can block for several ticks. This command never runs in an INST.

NET: LINE (integer)

Returns 1 if you are connected to the Babel server, or 0 if you aren't.

NET: PASS (string)

Returns the currently set username, as selected with PASS.

NET: PASS (command) nick_name (string) password (string)

Set nickname and password - do this before connecting with NET: LINE. If you set GAME "engine_netbabel_save_passwords" to 1 then the password for each 
nickname is saved in user.cfg, so you can specify an empty string for the password after the first time. The nickname is saved with the serialised 
world, so is cleared when you start a new world. You can use NET: PASS to retrieve the user later.

NET: RAWE (integer)

Returns an internal error code from Babel. Only use this for display and diagnostic purpose, use NET: ERRA for documented error codes which you can 
rely on.

NET: RUSO (command) store_result (variable)

Returns (into store_result) a random user who is currently online. Returns an empty string if you're offline, or if you aren't using the Docking 
Station Babel server module. Since you're online, it can return yourself (especially if you're the only person online!). The user is also only likely  
to be online - they could have gone offline since the server replied to you.
This is a command rather than an integer r-value because it is blocking. This means that it might take several ticks before the server returns the 
result. In this sense it is similar to a command like OVER, so it does not run in an INST. You should use LOCK if you don't want your script 
interrupting.

NET: STAT (command) time_online (variable) users_online (variable) bytes_received (variable) bytes_sent (variable)

Returns statistics for the current Babel connection, or -1 if offline. This command can block (doesn't execute in an INST). The statistics are:
time_online - Time online in milliseconds
users_online - Number of users currently connected to the server
bytes_received - Bytes received by the client
bytes_sent - Bytes sent from the client

NET: ULIN (integer) user_id (string)

Returns 1 if the specified user is online, or 0 if they are offline. This is slow (i.e. has to call the server) unless the user is in the whose wanted 
register of any agent. Use NET: WHON to add a user to the register.

NET: UNIK (command) user_id (string) store_result (variable)

Returns the specified user's screen or nick name. Returns empty string if offline, or no such user. This command can take many ticks to execute while 
the server is quizzed, like NET: RUSO.

NET: USER (string)

Returns the user's numeric Babel id, or an empty string if they have never logged in with this world since they last changed user name.

NET: WHAT (string)

For debugging only. Returns a string describing what the upload/query network thread is currently doing. For example, it may be fetching a random  
online user, or uploading some creature history. Returns an emptry string if it is doing nothing.

NET: WHOD (command)

Dump debugging information about the whose wanted register.

NET: WHOF (command) user (string)

Removes a user from the whose wanted list for the target agent. See NET: WHON.

NET: WHON (command) user (string)

Add a user to the whose wanted register for the target agent. Scripts User Online and User Offline are now called on this agent when that user goes  
on  or offline, or indeed when the local user goes offline. Use NET: WHOF to remove them from the register. This command is blocking, it can take  
several ticks to return.

NET: WHOZ (command)

Zap the target agent's whose wanted register, removing all entries.

NET: WRIT (command) user_id (string) channel (string) message_id (integer) param_1 (anything) param_2 (anything)

Send a message to a remote machine, as specified by the user identifier. All agents which are NET: HEARing on the given channel will receive the  
message, and run the appropriate script. If the specified user is offline, then the message is discarded. The FROM variable of the receiving script 
contains the user id of the sender, as a string. See also MESG WRIT.