//
// ViewController.swift
// Mytechnology App
//
// Created by MFG on 7.09.2020.
// Copyright © 2020 MFG. All rights reserved.
//
import UIKit
import RMQClient
import Foundation
//import XCTest
class ViewController: UIViewController {
@IBOutlet weak var editText: UITextField!
@IBOutlet weak var textView: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
var text:String = ""
//burada text degiskenimizi ayarliyoruz.
func send(message:String) { //bu fonksiyonun amaci mesaj gonderimi yapmak
print("Attempting to connect to local RabbitMQ broker")
let delegate = RMQConnectionDelegateLogger()
let tlsOptions = RMQTLSOptions(
peerName: "192.xxx.x.xx",
verifyPeer: true,
pkcs12: fixtureClientCertificatePKCS12() as Data,
pkcs12Password: CertificateFixtures.password
)
let conn = RMQConnection(uri: "amqp://test:te...@192.xxx.xx.xx:5671//",
tlsOptions: tlsOptions,
delegate: delegate)
conn.start()
//defer { conn.blockingClose() }
let ch = conn.createChannel()
let q = ch.queue("go")
let body = message.data(using: String.Encoding.utf8)!
q.publish(body)
//mesaj gonderimi islemini yapacak burasi
print("Sent \(message)")
}
//butona tiklandiginda asagisi calisacak
@IBAction func buttonClick(_ sender: UIButton) {
text = editText.text!
self.send(message: text) //burada ekrandan (kullanicidan) veri alinacak
textView.text = text //ekranda da yazdiralim dedim
}
//silmek istersek ekranda goruneni bu fonksiyon calisacak
@IBAction func clear(_ sender: UIButton) {
textView.text = "Cleared"
editText.text = ""
}
//bu lazim olacak tls icin..
fileprivate func fixtureClientCertificatePKCS12() -> Data {
do {
return try CertificateFixtures.guestBunniesP12()
} catch {
fatalError("Failed to load the fixture client certificate")
}
}
}
//burasi ulasilmasi istenen dosyalara gidiyor, sifrede var..
class CertificateFixtures {
static let password = "bunnies"
static func guestBunniesP12() throws -> Data {
let bundle = Bundle.init(for: self)
//print("aaa")
guard let certURL = bundle.url(forResource: "client_key",
withExtension: "p12", subdirectory: "ios_tls_mfg") else {
let err = "Failed to load client_key.p12 from the bundle! Resourcee path: \(bundle.resourcePath!)"
print("error mfg errrorrr")
preconditionFailure(err)
}
return try Data(contentsOf: certURL)
}
}
~~~~code finished~~~~
~~~~the error i am getting~~~~
Attempting to connect to local RabbitMQ broker
Sent mfg_deneme
2020-09-17 16:01:24.015097+0300 ios_mqtt[93340:2640719] Received connection: <RMQConnection: 0x600001d1cbd0> disconnectedWithError: Error Domain=kCFStreamErrorDomainSSL Code=-9807 "(null)" UserInfo={NSLocalizedRecoverySuggestion=Error code definition can be found in Apple's SecureTransport.h}
2020-09-17 16:01:38.975724+0300 ios_mqtt[93340:2640720] Received connection: <RMQConnection: 0x600001d1cbd0> failedToConnectWithError: Error Domain=com.rabbitmq.rabbitmq-objc-client Code=1 "Handshake timed out." UserInfo={NSLocalizedDescription=Handshake timed out.}
2020-09-17 16:01:38.975823+0300 ios_mqtt[93340:2641282] Will start recovery for connection: <RMQConnection: 0x600001d1cbd0>
2020-09-17 16:01:38.975848+0300 ios_mqtt[93340:2640719] Starting recovery for connection: <RMQConnection: 0x600001d1cbd0>
2020-09-17 16:01:39.346433+0300 ios_mqtt[93340:2640720] Received connection: <RMQConnection: 0x600001d1cbd0> disconnectedWithError: Error Domain=kCFStreamErrorDomainSSL Code=-9807 "(null)" UserInfo={NSLocalizedRecoverySuggestion=Error code definition can be found in Apple's SecureTransport.h}
~~~~the error i am getting is finished~~~~
--
You received this message because you are subscribed to a topic in the Google Groups "rabbitmq-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rabbitmq-users/ZMgHrBSvCss/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/7ff97f2b-7c43-4732-b332-da01fb6ff199n%40googlegroups.com.