本文整理匯總了Golang中github.com/goxmpp/goxmpp/stream.ServerStream.ServerName方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServerStream.ServerName方法的具體用法?Golang ServerStream.ServerName怎麽用?Golang ServerStream.ServerName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/goxmpp/goxmpp/stream.ServerStream
的用法示例。
在下文中一共展示了ServerStream.ServerName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Handle
func (self *BindElement) Handle(strm stream.ServerStream, opts features.Options) error {
request_id := opts.(*iq.IQElement)
// FIXME(goxmpp): 2014-04-03: auth check, state presence check, resource check required
var state *BindState
strm.State().Get(&state)
if state.VerifyResource(self.Resource) {
state.Resource = self.Resource
} else {
// TODO(goxmpp): 2014-04-03
}
var authState *auth.AuthState
strm.State().Get(&authState)
strm.SetClientJID(authState.UserName + "@" + strm.ServerName() + "/" + state.Resource)
log.Printf("Bound to JID: %#v", strm.ClientJID())
// TODO(goxmpp): 2014-04-03: might be easier to just use original IQ?
response_iq := iq.NewIQElement()
response_iq.Type = "result"
response_iq.ID = request_id.ID
response_iq.AddElement(&BindElement{JID: strm.ClientJID()})
if err := strm.WriteElement(response_iq); err != nil {
return err
}
return nil
}