-
Notifications
You must be signed in to change notification settings - Fork 1
Networking
This is just a concept and is not a priority at the moment at all. I might implement this, but I am not sure.
Idea is that you can place special routers, and you can set a name and a password for your WiFi. To have bots use the network, use the network module as specified below.
Network will generate a unique ID for every bot that has connected to it, and this id will always remain the same whenever the bot reconnects! It is perfectly fine to use this id for managing per-client data. Also, it is possible to assign a name to each bot connected to the network, and these names will be saved for this network only. I don't know yet, but I might add a special module like network_router that's only accessible to the router, and you can program the router itself.
Connecting to the network:
import network
function main() {
network.setTargetNetwork("NETWORK_ID", "NETWORK_PASSWORD")
}When a bot successfully connects to the network, it will emit the connect event. Here's an example on how to handle the connect event:
@event("network", "connect")
function on_network_connect(client_id) {
print("I have connected to the network! My ID is: " + client_id)
}When a bot receives a message from another bot, it will emit the message_received event. I still haven't decided what type of data can be transfered from bot to bot. I'm thinking strings, ints, maybe records.
To send a message to a specific bot, you can use the network.send function.
@event("network", "message_receive")
function on_message(sender_id, message) {
print("Received " + message + " from " + sender_id)
network.send(sender_id, "Hello to you too!")
}