public void StartAsHost (string name, Action<ResponseType> response) {
#if RESET_ON_REGISTER
Emit ("socketReset", (SocketIOEvent e) => {
#endif
// Register and create the room
connection.name = name;
JSONObject obj = JSONObject.Create ();
obj.AddField ("name", name);
obj.AddField ("maxClientCount", 4);
Emit<Response.CreateRoom> ("createRoom", obj, (Response.CreateRoom res) => {
// If someone else already has this name, don't continue
if (!res.nameTaken) {
// Listen for clients joining the room
On("updateClients", (SocketIOEvent ev) => {
if (clientsUpdated != null)
clientsUpdated (ev.Deserialize<Response.ClientList> ().ClientNames);
});
// Update ConnectionInfo
Register (res.client._id, res.room);
}
response (res.nameTaken ? ResponseType.NameTaken : ResponseType.Success);
});
#if RESET_ON_REGISTER
});
#endif
}