@@ -56,11 +56,11 @@ void OnEntityQueryResponse(const Worker_EntityQueryResponseOp* op) {
56
56
}
57
57
58
58
void OnAddEntity (const Worker_AddEntityOp * op ) {
59
- printf ("received add entity op (entity: %" PRId64 ")\n" , op -> entity_id );
59
+ printf ("received add entity op (entity: %" PRId64 ")\n" , op -> entity_id );
60
60
}
61
61
62
62
void OnRemoveEntity (const Worker_RemoveEntityOp * op ) {
63
- printf ("received remove entity op (entity: %" PRId64 ")\n" , op -> entity_id );
63
+ printf ("received remove entity op (entity: %" PRId64 ")\n" , op -> entity_id );
64
64
}
65
65
66
66
void OnAddComponent (const Worker_AddComponentOp * op ) {
@@ -125,7 +125,9 @@ int main(int argc, char** argv) {
125
125
printf ("Connects to SpatialOS\n" );
126
126
printf (" <hostname> - hostname of the receptionist to connect to.\n" );
127
127
printf (" <port> - port to use\n" );
128
- printf (" <worker_id> - name of the worker assigned by SpatialOS. A random prefix will be added to it to ensure uniqueness.\n" );
128
+ printf (
129
+ " <worker_id> - name of the worker assigned by SpatialOS. A random prefix will be "
130
+ "added to it to ensure uniqueness.\n" );
129
131
return EXIT_FAILURE ;
130
132
}
131
133
@@ -148,6 +150,14 @@ int main(int argc, char** argv) {
148
150
Worker_ConnectionFuture_Destroy (connection_future );
149
151
free (worker_id );
150
152
153
+ if (Worker_Connection_GetConnectionStatusCode (connection ) !=
154
+ WORKER_CONNECTION_STATUS_CODE_SUCCESS ) {
155
+ printf ("failed to connect to receptionist. reason: %s\n" ,
156
+ Worker_Connection_GetConnectionStatusDetailString (connection ));
157
+ Worker_Connection_Destroy (connection );
158
+ return EXIT_FAILURE ;
159
+ }
160
+
151
161
/* Send a test message. */
152
162
Worker_LogMessage message = {WORKER_LOG_LEVEL_WARN , "Client" , "Connected successfully" , NULL };
153
163
Worker_Connection_SendLogMessage (connection , & message );
@@ -210,4 +220,6 @@ int main(int argc, char** argv) {
210
220
}
211
221
212
222
Worker_Connection_Destroy (connection );
223
+
224
+ return EXIT_SUCCESS ;
213
225
}
0 commit comments