Rev | Line | |
---|
[4940] | 1 | package com.joelpm.bidiMessages.server;
|
---|
| 2 |
|
---|
| 3 | import org.apache.thrift.TException;
|
---|
| 4 | import org.apache.thrift.protocol.TBinaryProtocol;
|
---|
| 5 | import org.apache.thrift.transport.TSocket;
|
---|
| 6 | import org.apache.thrift.transport.TTransport;
|
---|
| 7 | import com.joelpm.bidiMessages.generated.Message;
|
---|
| 8 | import com.joelpm.bidiMessages.generated.MessageService;
|
---|
| 9 | import com.joelpm.bidiMessages.generated.MessageService.Iface;
|
---|
| 10 |
|
---|
| 11 | /**
|
---|
| 12 | * This class is a stub that the server can use to send messages back
|
---|
| 13 | * to the client.
|
---|
| 14 | *
|
---|
| 15 | * @author Joel Meyer
|
---|
| 16 | */
|
---|
| 17 | public class MessageServiceClient implements Iface {
|
---|
| 18 | protected final TTransport transport;
|
---|
| 19 | protected final String addy;
|
---|
| 20 | protected final int port;
|
---|
| 21 | protected final MessageService.Client client;
|
---|
| 22 |
|
---|
| 23 | public MessageServiceClient(TTransport transport) {
|
---|
| 24 | TSocket tsocket = (TSocket)transport;
|
---|
| 25 | this.transport = transport;
|
---|
| 26 |
|
---|
| 27 | this.client = new MessageService.Client(new TBinaryProtocol(transport));
|
---|
| 28 | this.addy = tsocket.getSocket().getInetAddress().getHostAddress();
|
---|
| 29 | this.port = tsocket.getSocket().getPort();
|
---|
| 30 |
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | public String getAddy() {
|
---|
| 34 | return addy;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | public void sendMessage(Message msg) throws TException {
|
---|
| 38 | this.client.sendMessage(msg);
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
| 41 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.