SocketIO using swift











up vote
-2
down vote

favorite












I'm having trouble using blockexplorer API. here are the docs: https://blockexplorer.com/api-ref.
I was trying to print a new transaction in the console, but the only thing that I get is the message that it connects to the socket. Here is the code:



import UIKit
import SocketIO

class ViewController: UIViewController {

let manager = SocketManager(socketURL: URL(string: "https://blockexplorer.com/")!)

override func viewDidLoad() {
super.viewDidLoad()
let socket = manager.defaultSocket
socket.on(clientEvent: .connect) { (data, ack) in
socket.emit("subscribe", "inv")
print("socket connected")
}

socket.on("tx") { data, ack in
print("SUCCESS: (data)")

}
socket.connect()
}
}


Long story short i was trying to implement in swift that have been done in javascript in the docs:



<html>
<body>
<script src="https://blockexplorer.com/socket.io/socket.io.js"> </script>
<script>
eventToListenTo = 'tx'
room = 'inv'

var socket = io("https://blockexplorer.com/");
socket.on('connect', function() {
// Join the room.
socket.emit('subscribe', room);
})
socket.on(eventToListenTo, function(data) {
console.log("New transaction received: " + data.txid)
})
</script>
</body>
</html>









share|improve this question




















  • 1




    If you check their website it seems the transactions handler have some issues (blockexplorer.com). The web exemple does not work for me.
    – Yannick Loriot
    Nov 10 at 18:23










  • ohhh.. thank you for pointing this to me
    – 0NLY G0D
    Nov 10 at 18:33















up vote
-2
down vote

favorite












I'm having trouble using blockexplorer API. here are the docs: https://blockexplorer.com/api-ref.
I was trying to print a new transaction in the console, but the only thing that I get is the message that it connects to the socket. Here is the code:



import UIKit
import SocketIO

class ViewController: UIViewController {

let manager = SocketManager(socketURL: URL(string: "https://blockexplorer.com/")!)

override func viewDidLoad() {
super.viewDidLoad()
let socket = manager.defaultSocket
socket.on(clientEvent: .connect) { (data, ack) in
socket.emit("subscribe", "inv")
print("socket connected")
}

socket.on("tx") { data, ack in
print("SUCCESS: (data)")

}
socket.connect()
}
}


Long story short i was trying to implement in swift that have been done in javascript in the docs:



<html>
<body>
<script src="https://blockexplorer.com/socket.io/socket.io.js"> </script>
<script>
eventToListenTo = 'tx'
room = 'inv'

var socket = io("https://blockexplorer.com/");
socket.on('connect', function() {
// Join the room.
socket.emit('subscribe', room);
})
socket.on(eventToListenTo, function(data) {
console.log("New transaction received: " + data.txid)
})
</script>
</body>
</html>









share|improve this question




















  • 1




    If you check their website it seems the transactions handler have some issues (blockexplorer.com). The web exemple does not work for me.
    – Yannick Loriot
    Nov 10 at 18:23










  • ohhh.. thank you for pointing this to me
    – 0NLY G0D
    Nov 10 at 18:33













up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











I'm having trouble using blockexplorer API. here are the docs: https://blockexplorer.com/api-ref.
I was trying to print a new transaction in the console, but the only thing that I get is the message that it connects to the socket. Here is the code:



import UIKit
import SocketIO

class ViewController: UIViewController {

let manager = SocketManager(socketURL: URL(string: "https://blockexplorer.com/")!)

override func viewDidLoad() {
super.viewDidLoad()
let socket = manager.defaultSocket
socket.on(clientEvent: .connect) { (data, ack) in
socket.emit("subscribe", "inv")
print("socket connected")
}

socket.on("tx") { data, ack in
print("SUCCESS: (data)")

}
socket.connect()
}
}


Long story short i was trying to implement in swift that have been done in javascript in the docs:



<html>
<body>
<script src="https://blockexplorer.com/socket.io/socket.io.js"> </script>
<script>
eventToListenTo = 'tx'
room = 'inv'

var socket = io("https://blockexplorer.com/");
socket.on('connect', function() {
// Join the room.
socket.emit('subscribe', room);
})
socket.on(eventToListenTo, function(data) {
console.log("New transaction received: " + data.txid)
})
</script>
</body>
</html>









share|improve this question















I'm having trouble using blockexplorer API. here are the docs: https://blockexplorer.com/api-ref.
I was trying to print a new transaction in the console, but the only thing that I get is the message that it connects to the socket. Here is the code:



import UIKit
import SocketIO

class ViewController: UIViewController {

let manager = SocketManager(socketURL: URL(string: "https://blockexplorer.com/")!)

override func viewDidLoad() {
super.viewDidLoad()
let socket = manager.defaultSocket
socket.on(clientEvent: .connect) { (data, ack) in
socket.emit("subscribe", "inv")
print("socket connected")
}

socket.on("tx") { data, ack in
print("SUCCESS: (data)")

}
socket.connect()
}
}


Long story short i was trying to implement in swift that have been done in javascript in the docs:



<html>
<body>
<script src="https://blockexplorer.com/socket.io/socket.io.js"> </script>
<script>
eventToListenTo = 'tx'
room = 'inv'

var socket = io("https://blockexplorer.com/");
socket.on('connect', function() {
// Join the room.
socket.emit('subscribe', room);
})
socket.on(eventToListenTo, function(data) {
console.log("New transaction received: " + data.txid)
})
</script>
</body>
</html>






javascript swift socket.io






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 18:06









Yannick Loriot

5,94522545




5,94522545










asked Nov 10 at 17:59









0NLY G0D

297




297








  • 1




    If you check their website it seems the transactions handler have some issues (blockexplorer.com). The web exemple does not work for me.
    – Yannick Loriot
    Nov 10 at 18:23










  • ohhh.. thank you for pointing this to me
    – 0NLY G0D
    Nov 10 at 18:33














  • 1




    If you check their website it seems the transactions handler have some issues (blockexplorer.com). The web exemple does not work for me.
    – Yannick Loriot
    Nov 10 at 18:23










  • ohhh.. thank you for pointing this to me
    – 0NLY G0D
    Nov 10 at 18:33








1




1




If you check their website it seems the transactions handler have some issues (blockexplorer.com). The web exemple does not work for me.
– Yannick Loriot
Nov 10 at 18:23




If you check their website it seems the transactions handler have some issues (blockexplorer.com). The web exemple does not work for me.
– Yannick Loriot
Nov 10 at 18:23












ohhh.. thank you for pointing this to me
– 0NLY G0D
Nov 10 at 18:33




ohhh.. thank you for pointing this to me
– 0NLY G0D
Nov 10 at 18:33

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241873%2fsocketio-using-swift%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241873%2fsocketio-using-swift%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Coverage of Google Street View

Full-time equivalent

Surfing