本文整理汇总了Golang中gopkg/in/igm/sockjs-go/v2/sockjs.Session.Close方法的典型用法代码示例。如果您正苦于以下问题:Golang Session.Close方法的具体用法?Golang Session.Close怎么用?Golang Session.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gopkg/in/igm/sockjs-go/v2/sockjs.Session
的用法示例。
在下文中一共展示了Session.Close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: sockjsHandler
func (k *Kite) sockjsHandler(session sockjs.Session) {
defer session.Close(0, "")
// This Client also handles the connected client.
// Since both sides can send/receive messages the client code is reused here.
c := k.NewClient("")
c.session = session
go c.sendHub()
c.wg.Add(1) // with sendHub we added a new listener
k.callOnConnectHandlers(c)
// Run after methods are registered and delegate is set
c.readLoop()
c.callOnDisconnectHandlers()
k.callOnDisconnectHandlers(c)
}
示例2: sockJSHandler
// sockJSHandler called when new client connection comes to SockJS endpoint.
func (app *Application) sockJSHandler(s sockjs.Session) {
c, err := newClient(app, s)
if err != nil {
logger.ERROR.Println(err)
return
}
defer c.clean()
logger.INFO.Printf("new SockJS session established with uid %s\n", c.uid())
for {
if msg, err := s.Recv(); err == nil {
err = c.message([]byte(msg))
if err != nil {
logger.ERROR.Println(err)
s.Close(CloseStatus, "error handling message")
break
}
continue
}
break
}
}
示例3: closeHandler
func closeHandler(conn sockjs.Session) { conn.Close(3000, "Go away!") }
示例4: accessDenied
func accessDenied(s sockjs.Session) error {
return s.Close(http.StatusForbidden, http.StatusText(http.StatusForbidden))
}