David Reiss | 7f42bcf | 2008-01-11 20:59:12 +0000 | [diff] [blame] | 1 | // |
| 2 | // TServer.cs |
| 3 | // |
| 4 | // Begin: Dec 3, 2007 |
David Reiss | 0c90f6f | 2008-02-06 22:18:40 +0000 | [diff] [blame] | 5 | // Authors: |
David Reiss | 7f42bcf | 2008-01-11 20:59:12 +0000 | [diff] [blame] | 6 | // Will Palmeri <wpalmeri@imeem.com> |
| 7 | // |
| 8 | // Distributed under the Thrift Software License |
| 9 | // |
| 10 | // See accompanying file LICENSE or visit the Thrift site at: |
| 11 | // http://developers.facebook.com/thrift/using |
| 12 | |
| 13 | using System; |
| 14 | using System.Collections.Generic; |
| 15 | using Thrift.Protocol; |
| 16 | using Thrift.Transport; |
| 17 | |
| 18 | namespace Thrift.Server |
| 19 | { |
| 20 | public abstract class TServer |
| 21 | { |
| 22 | /** |
| 23 | * Core processor |
| 24 | */ |
| 25 | protected TProcessor processor; |
| 26 | |
| 27 | /** |
| 28 | * Server transport |
| 29 | */ |
| 30 | protected TServerTransport serverTransport; |
| 31 | |
| 32 | /** |
| 33 | * Input Transport Factory |
| 34 | */ |
| 35 | protected TTransportFactory inputTransportFactory; |
| 36 | |
| 37 | /** |
| 38 | * Output Transport Factory |
| 39 | */ |
| 40 | protected TTransportFactory outputTransportFactory; |
| 41 | |
| 42 | /** |
| 43 | * Input Protocol Factory |
| 44 | */ |
| 45 | protected TProtocolFactory inputProtocolFactory; |
| 46 | |
| 47 | /** |
| 48 | * Output Protocol Factory |
| 49 | */ |
| 50 | protected TProtocolFactory outputProtocolFactory; |
| 51 | |
| 52 | /** |
| 53 | * Default constructors. |
| 54 | */ |
| 55 | |
| 56 | public TServer(TProcessor processor, |
| 57 | TServerTransport serverTransport) |
| 58 | :this(processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory()) |
| 59 | { |
| 60 | } |
| 61 | |
| 62 | public TServer(TProcessor processor, |
| 63 | TServerTransport serverTransport, |
| 64 | TTransportFactory transportFactory) |
| 65 | :this(processor, |
| 66 | serverTransport, |
| 67 | transportFactory, |
| 68 | transportFactory, |
| 69 | new TBinaryProtocol.Factory(), |
| 70 | new TBinaryProtocol.Factory()) |
| 71 | { |
| 72 | } |
| 73 | |
| 74 | public TServer(TProcessor processor, |
| 75 | TServerTransport serverTransport, |
| 76 | TTransportFactory transportFactory, |
| 77 | TProtocolFactory protocolFactory) |
| 78 | :this(processor, |
| 79 | serverTransport, |
| 80 | transportFactory, |
| 81 | transportFactory, |
| 82 | protocolFactory, |
| 83 | protocolFactory) |
| 84 | { |
| 85 | } |
| 86 | |
| 87 | public TServer(TProcessor processor, |
| 88 | TServerTransport serverTransport, |
| 89 | TTransportFactory inputTransportFactory, |
| 90 | TTransportFactory outputTransportFactory, |
| 91 | TProtocolFactory inputProtocolFactory, |
| 92 | TProtocolFactory outputProtocolFactory) |
| 93 | { |
| 94 | this.processor = processor; |
| 95 | this.serverTransport = serverTransport; |
| 96 | this.inputTransportFactory = inputTransportFactory; |
| 97 | this.outputTransportFactory = outputTransportFactory; |
| 98 | this.inputProtocolFactory = inputProtocolFactory; |
| 99 | this.outputProtocolFactory = outputProtocolFactory; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * The run method fires up the server and gets things going. |
| 104 | */ |
| 105 | public abstract void Serve(); |
David Reiss | dc815f5 | 2008-03-02 00:58:04 +0000 | [diff] [blame] | 106 | |
| 107 | public abstract void Stop(); |
David Reiss | 7f42bcf | 2008-01-11 20:59:12 +0000 | [diff] [blame] | 108 | } |
| 109 | } |
| 110 | |