var app = require('express')()
var server = require('http').Server(app)
var io = require('socket.io')(server)
server.listen(3000)
io.on('connection', function(socket) {
socket.on('comment', function(data) {
io.emit('comment', data)
})
}
socket.on("comment") {[weak self] data ,ack in
// получаешь комменты
}
let string = "Any String"
let style = NSMutableParagraphStyle()
style.alignment = .right
let attributes = [
NSForegroundColorAttributeName: UIColor.white,
NSParagraphStyleAttributeName: style
]
let attributedString = NSMutableAttributedString(string: string, attributes: attributes)
textView.attributedText = attributedString
record all;
player.addObserver(self, forKeyPath: "status", options: .new, context: nil)
// catch changes to status
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if keyPath == "status" {
// do something
}
}
func getJSON(rs: String, tx: String, completion: @escaping ((String) -> Void)) {
DispatchQueue.main.async { [weak self] in
guard let `self` = self else { return }
let inputURL = self.inputURL.text
let link = inputURL?.components(separatedBy: "wall")
let baseURL = "https://api.vk.com/method/wall.getById?posts=\(link![1])&access_token=87c166c356c35f6d835048af60d84014fa57d4eae&v=5.64"
let url = URL(string: baseURL)
let request = NSURLRequest(url: url! as URL)
let session = URLSession(configuration: .default)
session.dataTask(with: request as URLRequest) { (data, response, error) -> Void in
if error == nil {
let swiftyJSON = JSON(data: data!)
let response = swiftyJSON[rs].arrayValue
for tobject in response {
completion(tobject[tx].stringValue)
}
}
}
}
}