1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
package OpenSim::GridServer;
use strict;
use OpenSim::Utility;
use OpenSim::GridServer::Config;
use OpenSim::GridServer::GridManager;
sub getHandlerList {
my %list = (
"simulator_login" => \&_simulator_login,
"simulator_data_request" => \&_simulator_data_request,
"map_block" => \&_map_block,
"map_block2" => \&_map_block2, # this is better for the Region Monitor
);
return \%list;
}
# #################
# XMLRPC Handlers
sub _simulator_login {
my $params = shift;
my $region_data = undef;
my %response = ();
if ($params->{"UUID"}) {
$region_data = &OpenSim::GridServer::GridManager::getRegionByUUID($params->{"UUID"});
} elsif ($params->{"region_handle"}) {
$region_data = &OpenSim::GridServer::GridManager::getRegionByHandle($params->{"region_handle"});
} else {
$response{"error"} = "No UUID or region_handle passed to grid server - unable to connect you";
return \%response;
}
if (!$region_data) {
my %new_region_data = (
uuid => undef,
regionHandle => OpenSim::Utility::UIntsToLong($params->{region_locx}*256, $params->{region_locx}*256),
regionName => $params->{sim_name},
regionRecvKey => $OpenSim::Config::SIM_RECV_KEY,
regionSendKey => $OpenSim::Config::SIM_SEND_KEY,
regionSecret => $OpenSim::Config::SIM_RECV_KEY,
regionDataURI => "",
serverIP => $params->{sim_ip},
serverPort => $params->{sim_port},
serverURI => "http://" + $params->{sim_ip} + ":" + $params->{sim_port} + "/",
LocX => $params->{region_locx},
LocY => $params->{region_locy},
LocZ => 0,
regionAssetURI => $OpenSim::Config::ASSET_SERVER_URL,
regionAssetRecvKey => $OpenSim::Config::ASSET_RECV_KEY,
regionAssetSendKey => $OpenSim::Config::ASSET_SEND_KEY,
regionUserURI => $OpenSim::Config::USER_SERVER_URL,
regionUserRecvKey => $OpenSim::Config::USER_RECV_KEY,
regionUserSendKey => $OpenSim::Config::USER_SEND_KEY,
regionMapTextureID => $params->{"map-image-id"},
serverHttpPort => $params->{http_port},
serverRemotingPort => $params->{remoting_port},
);
eval {
&OpenSim::GridServer::GridManager::addRegion(\%new_region_data);
};
if ($@) {
$response{"error"} = "unable to add region";
return \%response;
}
$region_data = \%new_region_data;
}
my @region_neighbours_data = ();
my $region_list = &OpenSim::GridServer::GridManager::getRegionList($region_data->{locX}-1, $region_data->{locY}-1, $region_data->{locX}+1, $region_data->{locY}+1);
foreach my $region (@$region_list) {
next if ($region->{regionHandle} eq $region_data->{regionHandle});
my %neighbour_block = (
"sim_ip" => $region->{serverIP},
"sim_port" => $region->{serverPort},
"region_locx" => $region->{locX},
"region_locy" => $region->{locY},
"UUID" => $region->{uuid},
"regionHandle" => $region->{regionHandle},
);
push @region_neighbours_data, \%neighbour_block;
}
%response = (
UUID => $region_data->{uuid},
region_locx => $region_data->{locX},
region_locy => $region_data->{locY},
regionname => $region_data->{regionName},
estate_id => "1", # TODO ???
neighbours => \@region_neighbours_data,
sim_ip => $region_data->{serverIP},
sim_port => $region_data->{serverPort},
asset_url => $region_data->{regionAssetURI},
asset_recvkey => $region_data->{regionAssetRecvKey},
asset_sendkey => $region_data->{regionAssetSendKey},
user_url => $region_data->{regionUserURI},
user_recvkey => $region_data->{regionUserRecvKey},
user_sendkey => $region_data->{regionUserSendKey},
authkey => $region_data->{regionSecret},
data_uri => $region_data->{regionDataURI},
"allow_forceful_banlines" => "TRUE",
);
return \%response;
}
sub _simulator_data_request {
my $params = shift;
my $region_data = undef;
my %response = ();
if ($params->{"region_UUID"}) {
$region_data = &OpenSim::GridServer::GridManager::getRegionByUUID($params->{"region_UUID"});
} elsif ($params->{"region_handle"}) {
$region_data = &OpenSim::GridServer::GridManager::getRegionByHandle($params->{"region_handle"});
}
if (!$region_data) {
$response{"error"} = "Sim does not exist";
return \%response;
}
$response{"sim_ip"} = $region_data->{serverIP};
$response{"sim_port"} = $region_data->{serverPort};
$response{"http_port"} = $region_data->{serverHttpPort};
$response{"remoting_port"} = $region_data->{serverRemotingPort};
$response{"region_locx"} = $region_data->{locX};
$response{"region_locy"} = $region_data->{locY};
$response{"region_UUID"} = $region_data->{uuid};
$response{"region_name"} = $region_data->{regionName};
$response{"regionHandle"} = $region_data->{regionHandle};
return \%response;
}
sub _map_block {
my $params = shift;
my $xmin = $params->{xmin} || 980;
my $ymin = $params->{ymin} || 980;
my $xmax = $params->{xmax} || 1020;
my $ymax = $params->{ymax} || 1020;
my @sim_block_list = ();
my $region_list = &OpenSim::GridServer::GridManager::getRegionList($xmin, $ymin, $xmax, $ymax);
foreach my $region (@$region_list) {
my %sim_block = (
"x" => $region->{locX},
"y" => $region->{locY},
"name" => $region->{regionName},
"access" => 0, # TODO ? meaning unknown
"region-flags" => 0, # TODO ? unknown
"water-height" => 20, # TODO ? get from a XML
"agents" => 1, # TODO
"map-image-id" => $region->{regionMapTexture},
"regionhandle" => $region->{regionHandle},
"sim_ip" => $region->{serverIP},
"sim_port" => $region->{serverPort},
"sim_uri" => $region->{serverURI},
"uuid" => $region->{uuid},
"remoting_port" => $region->{serverRemotingPort},
);
push @sim_block_list, \%sim_block;
}
my %response = (
"sim-profiles" => \@sim_block_list,
);
return \%response;
}
sub _map_block2 {
my $params = shift;
my $xmin = $params->{xmin} || 980;
my $ymin = $params->{ymin} || 980;
my $xmax = $params->{xmax} || 1020;
my $ymax = $params->{ymax} || 1020;
my @sim_block_list = ();
my $region_list = &OpenSim::GridServer::GridManager::getRegionList2($xmin, $ymin, $xmax, $ymax);
foreach my $region (@$region_list) {
my %sim_block = (
"x" => $region->{locX},
"y" => $region->{locY},
"name" => $region->{regionName},
"access" => 0, # TODO ? meaning unknown
"region-flags" => 0, # TODO ? unknown
"water-height" => 20, # TODO ? get from a XML
"agents" => 1, # TODO
"map-image-id" => $region->{regionMapTexture},
"regionhandle" => $region->{regionHandle},
"sim_ip" => $region->{serverIP},
"sim_port" => $region->{serverPort},
"sim_uri" => $region->{serverURI},
"uuid" => $region->{uuid},
"remoting_port" => $region->{serverRemotingPort},
);
push @sim_block_list, \%sim_block;
}
my %response = (
"sim-profiles" => \@sim_block_list,
);
return \%response;
}
1;
|