本文整理汇总了Golang中github.com/twstrike/coyim/config.ConnectionPolicy类的典型用法代码示例。如果您正苦于以下问题:Golang ConnectionPolicy类的具体用法?Golang ConnectionPolicy怎么用?Golang ConnectionPolicy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConnectionPolicy类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Connect
// Connect connects to the server and starts the main threads
func (s *session) Connect(password string) error {
if !s.IsDisconnected() {
return nil
}
s.setStatus(CONNECTING)
if s.connectionLogger == nil {
s.connectionLogger = newLogger()
}
conf := s.GetConfig()
policy := config.ConnectionPolicy{
Logger: s.connectionLogger,
XMPPLogger: s.xmppLogger,
}
conn, err := policy.Connect(password, conf)
if err != nil {
s.alert(err.Error())
s.setStatus(DISCONNECTED)
return err
}
s.conn = conn
s.setStatus(CONNECTED)
s.conn.SignalPresence("")
go s.watchRoster()
go s.watchTimeout()
go s.watchStanzas()
return nil
}
开发者ID:grayleonard,项目名称:coyim,代码行数:36,代码来源:session.go
示例2: requestAndRenderRegistrationForm
func requestAndRenderRegistrationForm(server string, formHandler data.FormCallback, saveFn func(), errorFn func(error), df interfaces.DialerFactory, verifier tls.Verifier) {
policy := config.ConnectionPolicy{DialerFactory: df}
//TODO: this would not be necessary if RegisterAccount did not use it
conf := &config.Account{
Account: "@" + server,
Proxies: []string{"tor-auto://"},
}
//TODO: this should receive only a JID domainpart
_, err := policy.RegisterAccount(formHandler, conf, verifier)
if err != nil {
errorFn(err)
return
}
go saveFn()
}
开发者ID:rosatolen,项目名称:coyim,代码行数:19,代码来源:registration.go
示例3: requestAndRenderRegistrationForm
func requestAndRenderRegistrationForm(server string, formHandler data.FormCallback, saveFn func(), df func() interfaces.Dialer) error {
policy := config.ConnectionPolicy{DialerFactory: df}
//TODO: this would not be necessary if RegisterAccount did not use it
conf := &config.Account{
Account: "@" + server,
Proxies: []string{"tor-auto://"},
}
//TODO: this should receive only a JID domainpart
_, err := policy.RegisterAccount(formHandler, conf)
if err != nil {
//TODO: show something in the UI
log.Println("Registration failed:", err)
return err
}
go saveFn()
return nil
}
开发者ID:VKCheung,项目名称:coyim,代码行数:22,代码来源:registration.go
示例4: requestAndRenderRegistrationForm
func requestAndRenderRegistrationForm(server string, formHandler xmpp.FormCallback, saveFn func()) error {
policy := config.ConnectionPolicy{}
//TODO: this would not be necessary if RegisterAccount did not use it
conf := &config.Account{
Account: "@" + server,
RequireTor: true,
}
//TODO: this should receive only a JID domainpart
_, err := policy.RegisterAccount(formHandler, conf)
if err != nil {
//TODO: show something in the UI
log.Println("Registration failed:", err)
return err
}
go saveFn()
return nil
}
开发者ID:PMaynard,项目名称:coyim,代码行数:22,代码来源:registration.go
示例5: Connect
// Connect connects to the server and starts the main threads
func (s *session) Connect(password string, verifier tls.Verifier) error {
if !s.IsDisconnected() {
return nil
}
s.setStatus(CONNECTING)
conf := s.GetConfig()
policy := config.ConnectionPolicy{
Logger: s.connectionLogger,
XMPPLogger: s.xmppLogger,
DialerFactory: s.dialerFactory,
}
conn, err := policy.Connect(password, conf, verifier)
if err != nil {
s.setStatus(DISCONNECTED)
return err
}
if s.connStatus == CONNECTING {
s.conn = conn
s.setStatus(CONNECTED)
conn.SignalPresence("")
go s.watchRoster()
go s.getVCard()
go s.watchTimeout()
go s.watchStanzas()
} else {
if s.conn != nil {
s.conn.Close()
}
}
return nil
}
开发者ID:twstrike,项目名称:coyim,代码行数:39,代码来源:session.go
注:本文中的github.com/twstrike/coyim/config.ConnectionPolicy类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论