AppDelegate.swift 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright 2016, gRPC Authors All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import Cocoa
  17. @NSApplicationMain
  18. class AppDelegate: NSObject, NSApplicationDelegate {
  19. @IBOutlet weak var window: NSWindow!
  20. var echoProvider : Echo_EchoProvider!
  21. var insecureServer: Echo_EchoServer!
  22. var secureServer: Echo_EchoServer!
  23. func applicationDidFinishLaunching(_ aNotification: Notification) {
  24. // instantiate our custom-written application handler
  25. echoProvider = EchoProvider()
  26. // create and start a server for handling insecure requests
  27. insecureServer = Echo_EchoServer(address:"localhost:8081",
  28. provider:echoProvider)
  29. insecureServer.start()
  30. // create and start a server for handling secure requests
  31. let certificateURL = Bundle.main.url(forResource: "ssl", withExtension: "crt")!
  32. let keyURL = Bundle.main.url(forResource: "ssl", withExtension: "key")!
  33. secureServer = Echo_EchoServer(address:"localhost:8443",
  34. certificateURL:certificateURL,
  35. keyURL:keyURL,
  36. provider:echoProvider)
  37. secureServer.start()
  38. }
  39. }