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>
javascript swift socket.io
add a comment |
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>
javascript swift socket.io
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
add a comment |
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>
javascript swift socket.io
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
javascript swift socket.io
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
add a comment |
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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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