本文整理汇总了Golang中github.com/skycoin/skycoin/src/daemon/gnet.Connection类的典型用法代码示例。如果您正苦于以下问题:Golang Connection类的具体用法?Golang Connection怎么用?Golang Connection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Connection类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: onGnetDisconnect
// Triggered when an gnet.Connection terminates. Disconnect events are not
// pushed to a separate channel, because disconnects are already processed
// by a queue in the daemon.Run() select{}.
func (self *Daemon) onGnetDisconnect(c *gnet.Connection,
reason gnet.DisconnectReason) {
a := c.Addr()
logger.Info("%s disconnected because: %v", a, reason)
duration, exists := BlacklistOffenses[reason]
if exists {
self.Peers.Peers.AddBlacklistEntry(a, duration)
}
delete(self.OutgoingConnections, a)
delete(self.ExpectingIntroductions, a)
self.Visor.RemoveConnection(a)
self.removeIPCount(a)
self.removeConnectionMirror(a)
}
示例2: onGnetConnect
// Triggered when an gnet.Connection is connected
func (self *Daemon) onGnetConnect(c *gnet.Connection, solicited bool) {
self.onConnectEvent <- ConnectEvent{Addr: c.Addr(), Solicited: solicited}
}