This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func joinChatRoom(nickname: String, completion: () -> Void) { | |
guard let socket = manager?.defaultSocket else { | |
return | |
} | |
socket.emit(kConnectUser, nickname) | |
completion() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func closeConnection() { | |
guard let socket = manager?.defaultSocket else{ | |
return | |
} | |
socket.disconnect() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func establishConnection() { | |
guard let socket = manager?.defaultSocket else{ | |
return | |
} | |
socket.connect() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func establishConnection() { | |
guard let socket = manager?.defaultSocket else{ | |
return | |
} | |
socket.connect() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func configureSocketClient() { | |
guard let url = URL(string: kHost) else { | |
return | |
} | |
manager = SocketManager(socketURL: url, config: [.log(true), .compress]) | |
guard let manager = manager else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
extension UITableView { | |
static func emptyCell() -> UITableViewCell { | |
let cell = UITableViewCell() | |
cell.selectionStyle = .none | |
return cell | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
extension UIApplication { | |
static func jsonString(from object:Any) -> String? { | |
guard let data = jsonData(from: object) else { | |
return nil | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct Message: Codable { | |
var date: String? | |
var message: String? | |
var nickname: String? | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
final class MessageViewModel { | |
var arrMessage: KxSwift<[Message]> = KxSwift<[Message]>([]) | |
func getMessagesFromServer() { | |
SocketHelper.shared.getMessage { [weak self] (message: Message?) in | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ChatDetailsTableView: UITableView, UITableViewDelegate, UITableViewDataSource { | |
private var messageViewModel: MessageViewModel = MessageViewModel() | |
var nickName: String? | |
override func awakeFromNib() { | |
super.awakeFromNib() | |