added a proper header and switched to use TBinaryProtocolAcceleratedFactory, added some debug print msgs

This commit is contained in:
Ray Slakinski 2012-05-18 14:44:17 -04:00
parent c945aba23f
commit 769f960401

7
server.py Normal file → Executable file
View File

@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from helloworld import HelloWorld from helloworld import HelloWorld
from helloworld.ttypes import * from helloworld.ttypes import *
from helloworld.constants import * from helloworld.constants import *
@ -13,9 +16,11 @@ class HelloWorldHandler:
self.log = {} self.log = {}
def ping(self): def ping(self):
print 'Recieved Ping... returning pong'
return "pong" return "pong"
def sayHello(self, msg): def sayHello(self, msg):
print 'Recieved hello msg: %s' % msg
if msg.lang in ('kp', 'kr'): if msg.lang in ('kp', 'kr'):
hello = HELLO_IN_KOREAN hello = HELLO_IN_KOREAN
elif msg.lang == 'fr': elif msg.lang == 'fr':
@ -30,7 +35,7 @@ handler = HelloWorldHandler()
processor = HelloWorld.Processor(handler) processor = HelloWorld.Processor(handler)
transport = TSocket.TServerSocket('localhost', port=9090) transport = TSocket.TServerSocket('localhost', port=9090)
tfactory = TTransport.TBufferedTransportFactory() tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory() pfactory = TBinaryProtocol.TBinaryProtocolAcceleratedFactory()
server = TServer.TSimpleServer(processor, transport, tfactory, pfactory) server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)