Rev | Line | |
---|
[4940] | 1 | package com.joelpm.bidiMessages.client;
|
---|
| 2 |
|
---|
| 3 | import org.apache.thrift.TException;
|
---|
| 4 | import org.apache.thrift.protocol.TProtocol;
|
---|
| 5 | import com.joelpm.bidiMessages.generated.MessageService;
|
---|
| 6 |
|
---|
| 7 | /**
|
---|
| 8 | * The class responsible for reading and deserializing incoming messages.
|
---|
| 9 | * Should be run in its own thread.
|
---|
| 10 | *
|
---|
| 11 | * @author Joel Meyer
|
---|
| 12 | */
|
---|
| 13 | public class MessageReceiver extends ConnectionRequiredRunnable {
|
---|
| 14 | private final MessageService.Processor processor;
|
---|
| 15 | private final TProtocol protocol;
|
---|
| 16 |
|
---|
| 17 | public MessageReceiver(
|
---|
| 18 | TProtocol protocol,
|
---|
| 19 | MessageService.Iface messageService,
|
---|
| 20 | ConnectionStatusMonitor connectionMonitor) {
|
---|
| 21 | super(connectionMonitor, "Message Receiver");
|
---|
| 22 | this.protocol = protocol;
|
---|
| 23 | this.processor = new MessageService.Processor(messageService);
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | @Override
|
---|
| 27 | public void run() {
|
---|
| 28 | connectWait();
|
---|
| 29 | while (true) {
|
---|
| 30 | try {
|
---|
| 31 | while (processor.process(protocol, protocol) == true) { }
|
---|
| 32 | } catch (TException e) {
|
---|
| 33 | disconnected();
|
---|
| 34 | }
|
---|
| 35 | }
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.