person method
Declares someone using the system, and answers them.
Any part of an identity is enough: a person who signs up while the world
is open is declared by the phone number they will type. app is what
they use, on is where it runs; a person with no app is headless — the
script acts for them through the server.
Implementation
Person person(
String name, {
String? email,
String? phone,
String? userId,
String? password,
Launch? app,
WorldDevice on = const Studio(),
}) {
if (!_people.add(name)) {
throw ArgumentError.value(name, 'name', 'Two people have this name');
}
if (app != null) {
for (var MapEntry(:key, :value) in app.knobs.entries) {
try {
jsonEncode(value);
} on JsonUnsupportedObjectError {
throw ArgumentError.value(
value,
'knobs',
"$name's knob $key is not a value an app can be started with: "
'a string, a number, a bool, or a list or map of them',
);
}
}
}
var person = Person(
name,
email: email,
phone: phone,
userId: userId,
password: password,
app: app,
on: on,
);
_send(WorldMessage.person, personToJson(person));
return person;
}