Erlang 中的 Apple 推送通知(或在 Ruby 中改进?) [英] Apple Push Notification in Erlang (or improved in Ruby?)
问题描述
我目前在我的服务器上使用 Ruby 运行 Apple 推送通知.我想让一个人在 Erlang 中进行,因为我想使用一个主管来监视它.有没有人有任何可以帮助我的代码?
I currently have an Apple Push Notification running on my server in Ruby. I'd like to get one going in Erlang as I'd like to use a supervisor to keep watch over it. Does anyone have any code that they could help me with?
这是我的 Ruby 代码.我不喜欢这个当前实现的一件事是它似乎没有保持连接 - 它每天断开 2-3 次,并且在我重新连接后似乎第一次推送不会通过:
Here's my Ruby code. One thing I do not like about this current implementation is that it does not seem to stay connected - it disconnects 2-3 times a day, and it seems after I reconnect that the first push will not go through:
context = OpenSSL::SSL::SSLContext.new
context.cert = OpenSSL::X509::Certificate.new(File.read(cert))
context.key = OpenSSL::PKey::RSA.new(File.read(cert))
def connect_sockets(server, context)
sock = TCPSocket.new(server, 2195)
ssl = OpenSSL::SSL::SSLSocket.new(sock,context)
ssl.connect
return sock, ssl
end
sock, ssl = connect_sockets(server, context) # this is called to initially connect and also reconnect whenever disconnected.
如果 Erlang Push 不可行,那么我不介意坚持使用我的 Ruby,只要我可以保持我的连接活跃,也许可以通过 Erlang 来监督它.有谁知道这是否可能?
If Erlang Push isn't doable then I wouldn't mind sticking to my Ruby one as long as I can keep my connections alive, and perhaps supervise it through Erlang. Does anyone know if any of this is possible?
推荐答案
这个 关于使用 Erlang 的 Apple Push Notifications 的问题 也可能对此有用.
This question on Apple Push Notifications with Erlang might also be useful for this one.
这篇关于Erlang 中的 Apple 推送通知(或在 Ruby 中改进?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!