use of jmri.server.json.JsonConnection in project JMRI by JMRI.
the class JsonServer method handleClient.
// Handle communication to a client through inStream and outStream
@Override
public void handleClient(DataInputStream inStream, DataOutputStream outStream) throws IOException {
ObjectReader reader = this.mapper.reader();
JsonClientHandler handler = new JsonClientHandler(new JsonConnection(outStream));
// Start by sending a welcome message
handler.onMessage(JsonClientHandler.HELLO_MSG);
while (true) {
try {
handler.onMessage(reader.readTree((InputStream) inStream));
// Read the command from the client
} catch (IOException e) {
// attempt to close the connection and throw the exception
handler.dispose();
throw e;
} catch (NoSuchElementException nse) {
// so break out of the loop
break;
}
}
handler.dispose();
}
use of jmri.server.json.JsonConnection in project JMRI by JMRI.
the class JsonThrottleServiceFactoryTest method testGetSocketService.
/**
* Test of getSocketService method, of class JsonThrottleServiceFactory.
*/
@Test
public void testGetSocketService() {
JsonConnection connection = new JsonMockConnection((DataOutputStream) null);
JsonThrottleServiceFactory instance = new JsonThrottleServiceFactory();
JsonSocketService result = instance.getSocketService(connection);
Assert.assertNotNull(result);
Assert.assertTrue(JsonSocketService.class.isInstance(result));
}
use of jmri.server.json.JsonConnection in project JMRI by JMRI.
the class JsonUtilServiceFactoryTest method testGetSocketService.
/**
* Test of getSocketService method, of class JsonUtilServiceFactory.
*/
@Test
public void testGetSocketService() {
JsonConnection connection = new JsonMockConnection((DataOutputStream) null);
JsonUtilServiceFactory instance = new JsonUtilServiceFactory();
JsonUtilSocketService result = instance.getSocketService(connection);
assertNotNull(result);
}
Aggregations