1-- 2-- Licensed to the Apache Software Foundation (ASF) under one 3-- or more contributor license agreements. See the NOTICE file 4-- distributed with this work for additional information 5-- regarding copyright ownership. The ASF licenses this file 6-- to you under the Apache License, Version 2.0 (the 7-- "License"); you may not use this file except in compliance 8-- with the License. You may obtain a copy of the License at 9-- 10-- http://www.apache.org/licenses/LICENSE-2.0 11-- 12-- Unless required by applicable law or agreed to in writing, 13-- software distributed under the License is distributed on an 14-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15-- KIND, either express or implied. See the License for the 16-- specific language governing permissions and limitations 17-- under the License. 18-- 19 20module Main where 21 22 23import qualified Control.Exception 24import qualified Network 25 26import Thrift.Protocol.Binary 27import Thrift.Server 28import Thrift.Transport.Handle 29 30import qualified ThriftTestUtils 31 32import qualified Yowza 33import qualified Yowza_Client as Client 34import qualified Yowza_Iface as Iface 35 36 37data YowzaHandler = YowzaHandler 38instance Iface.Yowza_Iface YowzaHandler where 39 blingity _ = do 40 ThriftTestUtils.serverLog "SERVER: Got blingity" 41 return () 42 43 blangity _ = do 44 ThriftTestUtils.serverLog "SERVER: Got blangity" 45 return $ 31 46 47 48client :: (String, Network.PortID) -> IO () 49client addr = do 50 to <- hOpen addr 51 let ps = (BinaryProtocol to, BinaryProtocol to) 52 53 Client.blingity ps 54 55 rv <- Client.blangity ps 56 ThriftTestUtils.clientLog $ show rv 57 58 tClose to 59 60server :: Network.PortNumber -> IO () 61server port = do 62 ThriftTestUtils.serverLog "Ready..." 63 (runBasicServer YowzaHandler Yowza.process port) 64 `Control.Exception.catch` 65 (\(TransportExn s _) -> error $ "FAILURE: " ++ show s) 66 67main :: IO () 68main = ThriftTestUtils.runTest server client 69