@@ -56,11 +56,11 @@ void OnEntityQueryResponse(const Worker_EntityQueryResponseOp* op) {
5656}
5757
5858void 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 );
6060}
6161
6262void 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 );
6464}
6565
6666void OnAddComponent (const Worker_AddComponentOp * op ) {
@@ -125,7 +125,9 @@ int main(int argc, char** argv) {
125125 printf ("Connects to SpatialOS\n" );
126126 printf (" <hostname> - hostname of the receptionist to connect to.\n" );
127127 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" );
129131 return EXIT_FAILURE ;
130132 }
131133
@@ -148,6 +150,14 @@ int main(int argc, char** argv) {
148150 Worker_ConnectionFuture_Destroy (connection_future );
149151 free (worker_id );
150152
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+
151161 /* Send a test message. */
152162 Worker_LogMessage message = {WORKER_LOG_LEVEL_WARN , "Client" , "Connected successfully" , NULL };
153163 Worker_Connection_SendLogMessage (connection , & message );
@@ -210,4 +220,5 @@ int main(int argc, char** argv) {
210220 }
211221
212222 Worker_Connection_Destroy (connection );
223+ return EXIT_SUCCESS ;
213224}
0 commit comments